0

I am learning Ember, and I have an app that has nested routes. The outer route renders an index of products that acts as a sidebar, and the inner route renders the selected product.

So I have a setup like this in my coffeescript router:

@resource 'products', ->
    @resource 'product'

And then I have a template like so for product_types.js.emblem:

each product in controller
    .product<NEED_SOMETHING_HERE>

I want NEED_SOMETHING_HERE to give me an extra attribute that will allow me to add a style to the product which will be rendered in the inner route. A class "active", or something similar, is the convention I would use elsewhere. What is the Ember way to do this?

Steve H.
  • 6,912
  • 2
  • 30
  • 49
LAW
  • 1,099
  • 3
  • 12
  • 20
  • This helps: http://stackoverflow.com/questions/16124201/ember-js-how-to-communicate-data-between-a-parent-routes-controller-and-a-chil – user3995789 Sep 04 '14 at 09:04

1 Answers1

0

Ember actually does this automatically with the link-to helper!

Ember adds an "active" class when the link matches the current route

http://emberjs.com/guides/templates/links/#toc_the-code-link-to-code-helper