Multiple conditions for ui-sref-active
I am using version 0.2.17 of ui-router.
The problem is that I would like to use the possibility to have multiple rules for ui-sref-active. For example like this:
ui-sref-active="{'active': 'videos.*', 'active': 'files.*'}
Is this somehow possible? At the moment it only takes the last condition.
Having this same issue, thought maybe I was using the syntax incorrectly. It looks like it will work with multiple things, but only one of them can have the .* glob.
Hi, when used with the object literal syntax, ui-sref-active parses its argument as a plain JavaScript object: keys should be unique.
That's why only one of the conditions applies.
ui-sref-active="{'active': 'videos.*', 'active': 'files.*'}
+1
I'd consider ui-sref-active="{'active': ['videos.*', 'files.*']}
Hi! Is there any update on this? It's exactly what we need for our navbar!
+1
+1 no update for this for now, it will be useful !
I'd be happy to merge a PR (please add tests around here) https://github.com/angular-ui/ui-router/blob/5b54cbf89db3a908fae55485d2796ce79f4dea2e/test/stateDirectivesSpec.js#L410-L415
In the meantime,you can accomplish this with a little bit of shenanigans by nesting hidden ui-sref inside a parent ui-sref-active.
<button ui-sref-active="active" class="btn btn-success">
Foo is active
<div style="display: none" ui-sref="foo.**"></div>
</button>
See this example: http://plnkr.co/edit/URTdcIWcIgUAqa15PoH2?p=preview