I'm trying to set up a tabbed nav bar that displays content in a div based upon a clicked tab. I'm using ng-repeat in my HTML like so:
HTML:
<ul class ="sidebar-nav">
<li ng-repeat="category in categories" ng-click="category.method()">{{category.name}}</li>
</ul>
But rather than it calling a method to set it to the active tab when it is clicked, I am seeing that all of the tabs are listed when the page loads and the active tab does not change upon being clicked. Here is my angular:
$scope.setTab = function(activateTab) {
$scope.tab = activateTab;
console.log(activateTab);
};
$scope.categories = [
{
"name" : "Common Tools",
method : $scope.setTab(1)
},
...
I tried to set the tab using an anonymous function, as well as using an "id" number inside the individual categories, but I get the same behavior. Any advice?
method: function() { $scope.setTab(1); }? Also, where is$scope.tabbeing used to determine the active style/class?