1
votes

I'm trying to set element class attributes based on current route. This is inside a navigation handlebars partial included in the Application handlebars template.

In my ApplicationController I can do something like:

isUsers: ( ->
  @get('currentPath') == 'users.index'
).property('currentPath')

In the navigation template I want to do something like:

<a {{bind-attr class="isUsers:active:inactive"}} href="users"></a>

This doesn't work - inactive class is always set, even when in correct app path.

Any suggestions?

1

1 Answers

2
votes

If you are defining the isUsers property in the ApplicationController, then are you sure you are using it in the application.handlebars or whatever template used by the ApplicationController? If you are using in a template which has a different Controller, make sure you use the following in your controller.

App.MyController = App.Controller.extend
  needs: ['application']

In the template,

controllers.application.isUsers