I have links who get and remove a class when the path match, works perfect, the only problem now is: one of these links has no path so how can I remove the class from the link1 above after click on link2 ? I could insert the class on link2 "who has no path", so right now I wanna remove the class of link1 after click in link 2. any ideas guys?
Thank you.
html
<div class="sidebar-nav">
<ul>
<li ng-class="{'current':getLocation('/url/test')}">
<a href="#/url/test">link 1
<i class="pull-right fa fa-calendar-plus-o" aria-hidden="true"></i>
</a>
</li>
<li ng-click="current=!current" ng-class="{'current': current}" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
<a>link 2
<i class="pull-right fa fa-circle" aria-hidden="true"></i></span></a>
<div class="collapse collapse-styled" id="collapseExample">
<a href="#">sublink 1
<i class="pull-right fa fa-calendar" aria-hidden="true"></i>
</a>
<a href="#">sublink 2
<i class="pull-right fa fa-list" aria-hidden="true"></i>
</a>
</div>
</li>
</ul>
</div>
angular:
angular.module('components').controller('sidebarController', [
'$location',
'$scope',
'jquery',
function($location, $scope, $) {
'use strict';
$scope.getLocation = function(path) {
var Search = new RegExp('^' + path, '');
return !!Search.exec($location.path());
};
}
]);