0

Ember findBy方法返回undefined,我是 ember 新手,无法弄清楚我做错了什么。通过 Ember Inspector 查看时,我看到用户帐户数据存在于商店中。使用 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);
    });
4

2 回答 2

0

accounts不包含任何具有primaryundefined 属性的对象时将被返回。

于 2019-07-16T12:31:39.023 回答
0

你试过这样吗?

accounts.findBy('primary', true);

于 2016-08-18T20:11:04.123 回答