2014-08-28 39 views
2
MyEmberApp.ApplicationRoute = Ember.Route.extend({ 
    beforeModel: function() { 
    console.log(this); 
    console.log(this.controllerFor('application').get('currentPath')); // Undefined. 
    console.log(this.controllerFor('application').currentPath); // Undefined. 
    // console.log(this.controller.currentRouteName); // Undefined. 
    // console.log(Mars.__container__.lookup("controller:application").get("currentRouteName")); // Undefined. 
    // console.log(this.controllerFor("application").get("currentPath")); // Undefined. 
    // console.log(this.controllerFor("application").get("currentRouteName")); // Undefined. 

    this.transitionTo(THE ROUTE NAME I FIND...); 
    } 
}); 

我在做什么错?即使官方文件说我必须这样做http://emberjs.com/guides/understanding-ember/debugging/Ember的currentPath和currentRouteName始终未定义

回答

0

该文档无法指定您需要在ApplicationController上手动创建此属性。

MyEmberApp.ApplicationController = Ember.Controller.extend({ 
    currentPath: 'test12' 
}); 
+0

如何在集成测试中获得它? – SuperUberDuper 2015-01-20 13:35:21

0

On beforeModel hook你没有控制器准备好。尝试挂钩setupController。

setupController(controller, model) { 
    this._super(controller, model); 
    debugger; 
},