0
如果我在控制器中执行此操作,则会分配addressList属性。将afterModel中的数组分配给控制器属性给出无法委派设置错误
addressList : function() {
model.accounts.forEach(function (account) {
addressList.push(account.get("address"));
});
return addressList;
}.property(),
但是如果我做的afterModel钩相同的路线:
model.accounts.forEach(function (account) {
addressList.push(account.get("address"));
}
});
this.controllerFor("journey").set("addressList", addressList);
我得到错误:
Error while processing route: journey Assertion Failed: Cannot delegate set(.. to the 'content' property of object proxy .. its 'content' is undefined.
好的,有没有更好的方法来获得数组中的第一项,而不是在我的第一种方法中使用foreach? – FutuToad 2014-12-08 09:32:22
我在路径中使用afterModel的一个原因是,在所有模型数据已被返回后,控制器中似乎没有挂钩 – FutuToad 2014-12-08 10:43:23
您不需要挂钩,只需监听模型更改。像:'addressList:function(){...} .property('model')' – givanse 2014-12-08 14:58:54