1

For example, say I have:

  • a master-detail setup (a Widgets route, with a nested Widget route)
  • in the master template I model, which is Widget.all to a component that lays it out as a list of {{link-to}} each of which transitions to the widgets.widget route

...then what is/are the recommended way(s) in ember 2 to tell that component what the selected widget is, so it can highlight its link?

Michael Johnston
  • 5,298
  • 1
  • 29
  • 37

1 Answers1

0

Ember's routing infrastructure automatically handles adding active classes to links provided you're using the link-to helper.

See emberjs - how to mark active menu item using router infrastructure

If you want to use a tag besides an anchor tag, like an li, see: Create a <li class="active"> around an active {{linkTo}}

Community
  • 1
  • 1
mkirk
  • 3,965
  • 1
  • 26
  • 37
  • I need to be able to add the class to the li, and in any case, was primarily interested in the general case not the specific case. I do see however that you can write custom components that inherit from link-to, so that is a possibility for getting the active behaviour for free. – Michael Johnston Nov 16 '15 at 03:59
  • I've updated my answer to be specific to link to a li. – mkirk Nov 16 '15 at 23:06