我有一个名为group的模型,它有多个属性,我还想将我的id信息保存到其他属性,因为有些理由将模型信息传递给其他地方。
import DS from 'ember-data';
var group = DS.Model.extend({
groupId : DS.attr('string'),//want to duplicate id here
groupName: DS.attr('string'),
groupRegion: DS.attr('string'),
groupCountry: DS.attr('string'),
groupSegment: DS.attr('string'),
groupSubSegment: DS.attr('string'),
isSelected: DS.attr('boolean'),
isExpand: DS.attr('boolean')
});
export default group;
答案 0 :(得分:1)
您可以使用ready hook。
var group = DS.Model.extend({
groupId : DS.attr(),//want to duplicate id here
groupName: DS.attr('string'),
groupRegion: DS.attr('string'),
groupCountry: DS.attr('string'),
groupSegment: DS.attr('string'),
groupSubSegment: DS.attr('string'),
isSelected: DS.attr('boolean'),
isExpand: DS.attr('boolean'),
ready(){
this.set('groupId',this.get('id'));
}
});