Instead of this-
<li ui-sref-active="active">
<a ui-sref="posts.details">Posts</a>
</li>
You can do this-
<li ng-class="{active: $state.includes('posts')}">
<a ui-sref="posts.details">Posts</a>
</li>
Currently it doesn’t work. There is a discussion going on here (https://github.com/angular-ui/ui-router/pull/927) And, it will be added soon.
UPDATE:
For this to work, $state
should be available in view.
angular.module('xyz').controller('AbcController', ['$scope', '$state', function($scope, $state) {
$scope.$state = $state;
}]);
UPDATE [2]:
As of version 0.2.11
, it works out of the box. Please check the related issue: https://github.com/angular-ui/ui-router/issues/818