4
emberjs-1.0.0-RC-6.1EmberJS路線事件轉換
我的控制器:
Application.LoginController = Ember.Controller.extend({
loginFailed: false,
isProcessing: false,
isSlowConnection: false,
timeout: null,
login: function() {
/* some code */
},
success: function() {
this.reset();
},
failure: function() {
this.reset();
},
reset: function() {
clearTimeout(this.get("timeout"));
this.setProperties({
isProcessing: false,
isSlowConnection: false
});
}
});
我的路由:
Application.LoginRoute = Ember.Route.extend({
setupController: function(controller, model) {
controller.reset();
},
events: {
}
});
當我去 「/登錄」 爲第一次調用setupController。不過,我想每次使用事件(如轉換)來調用controller.reset()應用程序轉換爲登錄。
隨着 LOG_TRANSITIONS:真
我可以看到「Transitionned到‘登錄’」,在控制檯「Transitionned到‘anotherPage’」,所以我想知道是否有可能獲得事件,觸發那些日誌,在我的路由器中。
像:
Application.LoginRoute = Ember.Route.extend({
setupController: function(controller, model) {
controller.reset();
},
events: {
didTransition: function(reason) {
controller.reset();
}
}
});
謝謝你的掛鉤! –
有沒有「afterActivate」掛鉤? – daniel1426
@ daniel1426激活/取消激活路線後,激活「激活」和「停用」掛鉤。 –