My Angular app has several views. The index.html
file which has the <div ng-view></div>
also has a header/navbar that has links to each of these views.
The $routeProvider
is configured to load respective views and their controllers.
Considering this setup, where each of the views has its own controller, how do I add CSS class="active"
to the appropriate link in the header when navigating within the app?
Extra Info.:
I added ng-click="set_page_id(x)"
and ng-class={active: active_page_id === x}
to the links and realized there's no controller associated with the index.html
. I wrote a jQuery function to make this work by listening to click events but it doesn't work when a view itself calls another view. I wonder if there's a better, Angular way.