【发布时间】:2016-08-17 20:36:09
【问题描述】:
Ember findBy 方法返回 undefined,我是 ember 新手,无法弄清楚我做错了什么。通过 Ember Inspector 查看时,我看到 user 和 account 数据存在于商店中。使用 2.7.0 版本的 ember 和 ember 数据。
this.get('store').findRecord('user', userId,{'include': 'accounts'}).then((user) => {
this.set('currentUser', user);
return user.get('accounts');
}).then((accounts) =>{
this.set('allAccounts', accounts);
let account = accounts.findBy('primary');
this.set('currentAccount',account);
resolve();
}).catch((error) => {
reject(error);
});
【问题讨论】:
-
您已经在调试器中验证了其中一个帐户的
primary属性设置为true? -
是的,我可以验证它的存在。
-
我认为你需要添加一个截图,
accounts的样子。
标签: ember.js ember-data undefined findby