Naresh Naresh - 1 year ago 116
AngularJS Question

New Angular 1 Component Router - Highlighting the link associated with the active route

I have a navbar with two links:

<a ng-link="['Route1']">Route 1</a>
<a ng-link="['Route2']">Route 2</a>

I would like to highlight the link associated with the active route. Essentially, I would like to add a class called
to one of the two links above. What's the easiest way to do this for the new Angular 1 Component Router?

Answer Source

Angular 1 Component Router automatically adds the ng-link-active class to active ng-links.

If your version isn't adding this automatically, you are probably using an outdated version of the Component Router. I've been using this version which is a more recent compilation rather than the one stated on the docs (which is 0.2.0).

Let's hope they get it production-ready soon.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download