【发布时间】:2014-04-23 13:48:35
【问题描述】:
当我想在控制器操作中从服务器获取帐户时,例如:
account: false,
actions: {
// When the oAuth popup returns this method will be called
fetchUser: function(id)
{
// Get the account from the server
this.store.find('account', id).then(function(account)
{
this.set('account', account);
}, function(error)
{
console.log('error', error);
});
},
}
它会引发错误,因为this.set('account', account) 行上的“this”不再是控制器。我现在如何在这个 Promise 回调中在控制器上设置“帐户”?
【问题讨论】:
标签: javascript ember.js promise rsvp-promise