중첩 된 경로에서 오류가 발생하면 throw 된 오류 중 하나가 캐치 될 때까지 상위 경로까지 버블 링됩니다.
오류를 처리 할 수있는 루트 수준은 Application
입니다. 그러나 setupController
후크 ApplicationRoute
은 ErrorRoute
에서 undefined
컨텍스트로 전환 한 후에 트리거됩니다.
코드는, 여기에서 볼 수있다 : http://jsbin.com/ucanam/2563/edit (출력 콘솔에 주어진다) ApplicationRoute
에서
제가 ErrorRoute
에서 전환 후에 존재하는 초기 모델에 의지. undefined
으로 재설정되는 이유는 무엇이며 어떻게 해결해야합니까?오류 하위 구조
편집 :
는 여기에 몇 가지 관련 코드입니다 :
App = Ember.Application.create({});
App.Router.map(function() {
this.route('articles');
});
App.ApplicationRoute = Ember.Route.extend({
model: function() {
/* model hook is not being called when the error bubbles up (nor afterModel hook) */
/* This is the model expected in Application level */
return [
{"key1": "val1"},
{"key2": "val2"},
{"key3": "val3"}
];
},
setupController: function(controller, model) {
/* This hook is called in the usual scenario, when ApplicationRoute first
invoked, with same model as defined in the model hook */
/* However, it is also invoked after an error thrown from Articles Route,
what happens then is:
typeof model == "undefined" */
console.log("SetupController invoked in Application Route:", model);
}
});
App.ArticlesRoute = Ember.Route.extend({
model: function() {
/* The following throws the error */
Ember.$.ajax("http://");
}
});
링크는 좋지만 게시물 본문에도 관련 코드가 제공되어야합니다. –