Skip to content

Instantly share code, notes, and snippets.

@K0NRAD
Last active August 29, 2015 14:05
Show Gist options
  • Save K0NRAD/06f4f465b4bf57558ff1 to your computer and use it in GitHub Desktop.
Save K0NRAD/06f4f465b4bf57558ff1 to your computer and use it in GitHub Desktop.
Handle active state of bootstrap navbar
/*
USAGE:
<div class="header">
<ul class="nav nav-pills pull-right" ng-controller="NavbarCtrl">
<li ng-class="{active: isActive('/')}"><a ng-href="#">Home</a></li>
<li ng-class="{active: isActive('/about')}"><a ng-href="#/about">About</a></li>
</ul>
<h3 class="text-muted">My APP</h3>
</div>
*/
app.controller('NavbarCtrl', function($scope, $location){
$scope.isActive = function(viewLocation){
return viewLocation === $location.path();
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment