1

我需要从控制器中知道Ember中当前路由的名称。搜索后我找到了这个主题和这个主题,但是对我来说是有用的。我this.routeNamethis.get('currentPath')Ember 版本是1.1.2

4

1 回答 1

4

我知道如何做到这一点的唯一方法是要求application这样的控制器。

App.AfterController = Ember.Controller.extend({
  needs: ['application'],
  init: function() {
    alert('Current route is ' + this.get('controllers.application.currentPath'));
    this._super();
  }
});
于 2013-11-11T10:03:20.393 回答