我正在努力在 Ember 控制器中链接承诺。
为了说明我在JSBIN上做了一个例子
此处还包括 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()
});
任何意见,将不胜感激。