0
, 난 그렇게 같은 인 IndexController가 있다고Ember에서 다른 경로로 전환 할 때 메소드를 호출하는 방법은 무엇입니까?
App.IndexController = Ember.ArrayController.extend({
sortProperties: ['PicId'],
PicCreated: function() {
alert('Pic created');
}
});
을 수 있습니다 그리고 지금은 내 질문에 내가 전환에 PicCreated를 호출 할 어떻게
App.NewPic = Ember.Controller.extend({
// the initial value of the `search` property
model: this.get('model'),
needs: ["Index"], //says we need the Index controller for this
actions: {
var Pic= this.store.createRecord("PicList", obj);
PicList.save().then(function() {
this.transitionToRoute('Index');
});
}
});
NewPic
라는 다른 컨트롤러를 가지고있다. 나는 색인 페이지로 돌아가서 "Pic created"메시지를 보여줄 것이다.누군가 나를 도와 줄 수 있습니까?
App.NewPic = Ember.Controller.extend({
needs: ["index"],
actions: {
createPic: function() {
var newPicController = this;
var indexController = this.get('controllers.index');
// more code here ...
PicList.save().then(function() {
newPicController.transitionToRoute('index').then(function() {
// show th message
indexController.PicCreated();
});
});
}
}
});
: 당신이
PicCreated
방법을 전환이 완료되면 알 수 있도록
then
을 사용하고 호출 할 수 있도록