Я изо всех сил пытаюсь переложить обещания в контроллер Ember.Использование обещаний с Ember
Для иллюстрации я сделал пример вопроса о JSBIN here
включены также код Ember здесь:
App.IndexController = Ember.Controller.extend({
result_of_request: 'nothing',
first_request: function() {
// create a promise which is immediately resolved
var promise = new Ember.RSVP.Promise(function(resolve, reject){
resolve("first resolved");
});
// once the promise has resolved it should call the next function?
promise.then(function(data) {
// does log the data (has resolved)...
console.log("data is : " + data);
// but neither this
this.set("result_of_request", "first");
// nor this work
second_request();
});
}.property(),
second_request: function() {
console.log("second request");
}.property()
});
Любые советы будут оценены.
'this' не является контроллером внутри обратного вызова, а' second_request' является методом (свойством), а не функцией (переменной). – Bergi