I'm using a JSON service to list menu items (links). When navigating the different routes/pages I want an "active" class added to the link that is currently active (i.e. the page the user is on).
I've used this jsfiddle as a starting point: http://jsfiddle.net/p3ZMR/4/
I've also found several answers here on stackoverflow, but all of them are similar to the solution above.
But, that solution doesn't work if the links are generated via ng-repeat:
<ul class="main-menu">
<li ng-repeat="page in pages">
<a href="/#/{{page.id}}" active-link="active">{{page.name}}</a>
</li>
</ul>
It seems as if the directive is called before the controller adds the links.
Is there any way to get around this?
getClass('/#/' + page.id)and it would not be hard coded.