I'm trying to add an 'active' class to my link as follows:
<a href="#/requests/{{request.id}}/processes" active>Processes</a>
That produces output (chrome console)
<a href="#/requests/7cgSiSdaIR/processes" active="">Processes</a>
This is my directive:
.directive('active', function($location) {
return {
link: function(scope, el, attrs) {
if('#'+$location.path() == attrs.href) {
el.addClass('active');
}
}
}
})
When I get the value of attrs.href
via console.log, it is #/requests//processes
, that is, the binding has not yet been implemented.
How can I resolve this?