javascript - angular UI-Router: ui-sref-active on child element -


how can give child element of ui-sref anchor ui-sref-active class?

i tried in menu on anchors:

<a ui-sref="some.route">     <h2 ui-sref-active="selected">click here</h2> </a> 

but doesn't work. i'm new angular, maybe tell me i'm doing wrong?

there a working plunker

as stated in doc:

ui-sref-active

...
ui-sref-active can live on same element ui-sref or on parent element. first ui-sref-active found @ same level or above ui-sref used.
...

we need parent (or current) element. work:

<li ui-sref-active="selected">     <a ui-sref="home">home</a></li> <li ui-sref-active="selected">     <a ui-sref="parent">parent</a></li> <li  ui-sref-active="selected">     <a ui-sref="parent.child">parent.child</a></li> 

check in action here


Comments