Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 如何从模板中获取当前余烬应用程序路线_Ember.js - Fatal编程技术网

Ember.js 如何从模板中获取当前余烬应用程序路线

Ember.js 如何从模板中获取当前余烬应用程序路线,ember.js,Ember.js,我正在尝试根据当前路由设置元素类属性。这位于应用程序把手模板中包含的导航把手部分中 在我的ApplicationController中,我可以执行以下操作: isUsers: ( -> @get('currentPath') == 'users.index' ).property('currentPath') <a {{bind-attr class="isUsers:active:inactive"}} href="users"></a> 在导航模板中,我

我正在尝试根据当前路由设置元素类属性。这位于应用程序把手模板中包含的导航把手部分中

在我的ApplicationController中,我可以执行以下操作:

isUsers: ( ->
  @get('currentPath') == 'users.index'
).property('currentPath')
<a {{bind-attr class="isUsers:active:inactive"}} href="users"></a>
在导航模板中,我想执行以下操作:

isUsers: ( ->
  @get('currentPath') == 'users.index'
).property('currentPath')
<a {{bind-attr class="isUsers:active:inactive"}} href="users"></a>

这不起作用-始终设置非活动类,即使在正确的应用程序路径中也是如此


有什么建议吗?

如果您在ApplicationController中定义了
isUsers
属性,那么您确定您正在
应用程序中使用它。把手
或ApplicationController使用的任何模板?如果在具有不同控制器的模板中使用,请确保在控制器中使用以下内容

App.MyController = App.Controller.extend
  needs: ['application']
在模板中

controllers.application.isUsers