Update ember 2.6.2 to 2.7.0 - Uncaught TypeError: Cannot read property 'eachAttribute' of undefined
Update ember 2.6.2 to 2.7.0 - Uncaught TypeError: Cannot read property 'eachAttribute' of undefined
- ember@2.6.2 至 ember@2.7.0
- ember-data@2.9.0(但是当 运行 在 2.5.x 下时同样的错误)
以下在更新前运行良好。
出现以下错误:
Uncaught TypeError: Cannot read property 'eachAttribute' of undefined
我正在重新加载模型
this.modelFor('admin').get('ssoApplicationSubscriptions').reload();
当它开始执行 eachAttribute
循环时,我得到了错误。有趣的是,构造函数此时未定义。
这是模型定义
// Organisation
export default DS.Model.extend({
name: attr('string')
});
// Institution Organisation
export default Organisation.extend({
ssoApplicationSubscriptions: hasMany('sso-application-subscription', { polymorphic: true })
});
我正在使用 JSONAPIAdapter/Serializer。
我在这个问题上遇到了同样的问题,归结为我使用构造函数来获取多态模型的模型名称。
在我的例子中,我有电子邮件,电子邮件属于促销活动,它是多态的,所以它看起来像这样:
{{email.promotion.content.constructor.modelName}}
我所做的改变是这样的:
我将 promotion_type: DS.attr("string")
添加到我的 Email
模型
并更改模板以使用该属性:{{email.promotion_type}}
- ember@2.6.2 至 ember@2.7.0
- ember-data@2.9.0(但是当 运行 在 2.5.x 下时同样的错误)
以下在更新前运行良好。
出现以下错误:
Uncaught TypeError: Cannot read property 'eachAttribute' of undefined
我正在重新加载模型
this.modelFor('admin').get('ssoApplicationSubscriptions').reload();
当它开始执行 eachAttribute
循环时,我得到了错误。有趣的是,构造函数此时未定义。
这是模型定义
// Organisation
export default DS.Model.extend({
name: attr('string')
});
// Institution Organisation
export default Organisation.extend({
ssoApplicationSubscriptions: hasMany('sso-application-subscription', { polymorphic: true })
});
我正在使用 JSONAPIAdapter/Serializer。
我在这个问题上遇到了同样的问题,归结为我使用构造函数来获取多态模型的模型名称。 在我的例子中,我有电子邮件,电子邮件属于促销活动,它是多态的,所以它看起来像这样:
{{email.promotion.content.constructor.modelName}}
我所做的改变是这样的:
我将 promotion_type: DS.attr("string")
添加到我的 Email
模型
并更改模板以使用该属性:{{email.promotion_type}}