I'd like to set the 'active' class on an Ember link-to helper for more than one route, where the routes are not nested. ie. if I have a link to route1 I would like it to be active when the current route is route1 or route2.
Something, like:
{{#link-to 'route1' currentWhen="route1, route2"}}Things-N-Stuff{{/link-to}}
My next ideal scenario is set (or find) a boolean when the route is active and then do something like:
{{#link-to 'route1' class="isRoute1:active isRoute2:active"}}Not-as-good{{/link-to}}
But I'd rather pick it up for free. Perhaps there is a default isRoutename boolean that isn't in the docs yet...?
No answers yet. I ended up doing this:
{{#linkTo "things" tagName="li" href=false}}
<a {{bindAttr href="view.href"}} {{bindAttr class="isThingsLinkActive:active"}}>Things</a>
{{/linkTo}}
And then in the App.ApplicaitonController
isThingsLinkActive: function(){
return ['things.index','thing.index','stuff.index'].contains( this.get('currentPath') );
}.property('currentPath'),
It means I need to have something like thins in my app controller for each 'overloaded' link. Wouldn't it be cleaner to capture this entirely in the template using default flags/attributes generated by ember? I'm open to a more elegant solution... anyone?