angularjs - Angular-ui-router: ui-sref-active and nested states -


i using angular-ui-router , nested states in application, , have navigation bar. nav bar hand written, , uses ui-sref-active highlight current state. two-level navigation bar.

now, when in, products / categories both products (in level 1) , categories (in level 2) highlighted. however, using ui-sref-active, if in state products.categories state highlighted, not products.

is there way make products highlight in state?

instead of this-

<li ui-sref-active="active">     <a ui-sref="posts.details">posts</a> </li> 

you can this-

<li ng-class="{active: $state.includes('posts')}">     <a ui-sref="posts.details">posts</a> </li> 

currently doesn't work. there discussion going on here (https://github.com/angular-ui/ui-router/pull/927) and, added soon.

update:

for work, $state should available in view.

angular.module('xyz').controller('abccontroller', ['$scope', '$state', function($scope, $state) {    $scope.$state = $state; }]); 

more info

update [2]:

as of version 0.2.11, works out of box. please check related issue: https://github.com/angular-ui/ui-router/issues/818


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -