我试图检测何时发生路由转换.我已将此代码段放在最新版本的Ember(v1.0.0-pre.4)中,用于处理转换:
didTransition: function(infos) {
// Don't do any further action here if we redirected
if (infos[infos.length-1].handler.transitioned) { return; }
var appController = this.container.lookup('controller:application'),
path = routePath(infos);
set(appController, 'currentPath', path);
this.notifyPropertyChange('url');
if (get(this, 'namespace').LOG_TRANSITIONS) {
Ember.Logger.log("Transitioned into '" + path + "'");
}
},
Run Code Online (Sandbox Code Playgroud)
我将我的Ember应用程序设置为window.App = Ember.Application.create().
我注意到它调用了this.notifyPropertyChange('url');,但我试图将一个观察者附加到我的应用程序,App.Router或者App.Router.router我得到一个错误,因为它没有实现Ember.Observable.
如何更改路径路径而不为每条路线创建特殊的Ember.Route?