my route file
app.config(["$routeProvider",function($route)
{
$route.when("/",{
templateUrl : "partials/index.html",
controller : "AppCtrl"
}).when("/contact",{
templateUrl:"partials/contact.html",
controller:"ContactCtrl"
}).
when("/about-us",{
templateUrl:"partials/about.html",
controller:"AboutCtrl"
}).
when("/gallery",{
templateUrl:"partials/gallery.html",
controller:"GalleryCtrl"
}).
otherwise({
redirectTo:"/"
});
}]);
in my header.html partials i'm using HeaderCtrl controller
app.controller("HeaderCtrl",["$scope","$location",function($scope,$location)
{
$scope.location=$location.path().replace("/","");
}]);
my header.html
<ul ng-controller="HeaderCtrl">
<li ng-class="{active:location===''}"><a href="#">home</a></li>
<li ng-class="{active:location==='about-us'}"><a href="#/about-us">about us</a></li>
<li ng-class="{active:location==='gallery'}"><a href="#/gallery">gallery</a></li>
<li ng-class="{active:location==='contact'}"><a href="#/contact">contact</a></li>
</ul>
when the page reloads (actual refresh) then it works ie the class active is applied on the respective li but when i change the routes (by clicking on the menu items) it doesn't work
$scope.locationin your controller when the route changes.