我在组件内部,尝试在操作中添加新创建的实体:
var stakeholding = this.get('store').createRecord('stakeholding', {[...]});
var allCarings = this.get('allCarings');
allCarings.insertAt(0, stakeholding);
但我收到此错误消息:
TypeError: internalModel.getRecord is not a function
allCarings
在页面启动时初始化,如下所示:在组件内:
this.store.find('stakeholding', {[...]}).then(function(data){
_this.set('allCarings', data);
});
我应该如何正确地将我的实体添加到数组中?
答案 0 :(得分:0)
您应该使用allCarings
将记录添加到pushObject
数组:
var stakeholding = this.get('store').createRecord('stakeholding', {[...]});
var allCarings = this.get('allCarings');
allCarings.pushObject(stakeholding);
答案 1 :(得分:-1)
我是Ember的新手,并不确切知道为什么,但这对我有用:
allCarings.insertAt(0, stakeholding._internalModel);