如何使用ember.js从url更改启动模式?

如何使用ember.js从url更改启动模式?,ember.js,Ember.js,我已经使用ApplicationRoute获得了一个“从事件启动模式”,但是如果可能的话,我希望跟踪url中的模式更改 App.ApplicationRoute = Ember.Route.extend({ actions: { modal: function() { view = Ember.View.create({ templateName: "modal", controller: this.controller,

我已经使用ApplicationRoute获得了一个“从事件启动模式”,但是如果可能的话,我希望跟踪url中的模式更改

App.ApplicationRoute = Ember.Route.extend({
  actions: {
    modal: function() {
      view = Ember.View.create({
        templateName: "modal",
        controller: this.controller,
        content: []
      }).appendTo('body');
    }
  }
});

如果我更改url,如何触发模式以显示给定的上下文(使用url参数来构建它)?

根据您希望此行为的集中程度,您可以向应用程序控制器添加路径观察者:

App.ApplicationController = Ember.Controller.extend({
  //...
  currentPathDidChange: function () {
    switch(this.get('currentPath')){
      case 'foo-route.index':
        //trigger modal change
        break;
    }
  }.observes('currentPath')
  //...
});

这可以在一个位置。用你的例子,我可以把它连接到ApplicationController上?还是应用程序路径?@ToranBillups刚刚编辑了我的答案。可以从ApplicationController执行此操作。