New to AngularJS. I've got the following UL menu being controlled by
`ControllerHeader´:
<ul class="menu" ng-controller="ControllerHeader">
<li><a ng-class="{ active: isActive('/foo') }" href="#/foo">foo</a></li>
<li><a ng-class="{ active: isActive('/bar') }" href="#/bar">bar</a></li>
<li><a ng-class="{ active: isActive('/baz') }" href="#/baz">baz</a></li>
</ul>
Then I define `ControllerHeader´ and `isActive´ as given:
var app = angular.module('app', [ ]);
app.controller( 'ControllerHeader', ['$scope', '$location',
function ($scope, $location) {
$scope.isActive = function (location) {
console.log(location, $location.path());
return location === $location.path();
};
}
] );
What happens is that `isActive´ is called 3 * 3 times. Could someone
explain why? How can I fix it that such that it is called once per item?
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.