I have routes set in AngularJS like this:
$routeProvider
.when('/dashboard', {templateUrl:'partials/dashboard', controller:widgetsController})
.when('/lab', {templateUrl:'partials/lab', controller:widgetsController})
I have some links on the topbar styled as tabs. How can I add ‘active’ class to a tab depending on current template or url?
A way to solve this without having to rely on URLs is to add a custom attribute to every partial during
$routeProviderconfiguration, like this:Expose
$routein your controller:Set the
activeclass based on the current active tab: