【发布时间】:2013-12-15 21:24:23
【问题描述】:
我已经尝试了几个小时来弄清楚为什么这不起作用,但我似乎无法找到解决方案。
我正在尝试通过 REST 获取数据,对数据执行一些操作(例如过滤它),然后返回结果。
如果我只返回this.store.find('somthing'),这将非常有效。一旦我使用then() - 一切都会中断。
App.SongController = Ember.ObjectController.extend({
first: (function() {
return this.second();
}).property('first', '').volatile()
second: (function() {
var promise = Ember.Deferred.create();
var data = [{ id: 1, name: 'hi' }];
this.store.find('something').then(function (data) {
// Do something with the data..
// return the data
promise.resolve(data);
});
return promise;
}).property('second')
});
控制台错误:
Assertion failed: The value that #each loops over must be an Array. You passed <Ember.Deferred:ember350>
Uncaught TypeError: Object [object Object] has no method 'addArrayObserver'
Assertion failed: Emptying a view in the inBuffer state is not allowed and should not happen under normal circumstances. Most likely there is a bug in your application. This may be due to excessive property change notifications.
Uncaught Error: You cannot modify child views while in the inBuffer state
【问题讨论】:
-
我认为在某些路由模型中你返回songController.first() 或songController.second(),你能显示那个代码吗?
标签: javascript ember.js