Answer the question
In order to leave comments, you need to log in
What is the error in the description of the model?
I have the following description of the model:
export default DS.Model.extend({
initValue : attr('number', {
defaultValue: 0
}),
value: attr('number', {
defaultValue: function() {
var val = 0;
this.get('operations').forEach(function(operation) {
val += operation.get('value');
});
return this.get('initValue') + val;
}.property('[email protected]')
}),
operations: DS.hasMany('operation', {
async: true
})
});
Answer the question
In order to leave comments, you need to log in
export default DS.Model.extend({
initValue : attr('number', {
defaultValue: 0
}),
value: attr('number', {
defaultValue: function() {
var val = 0;
this.get('operations').forEach(function(operation) {
val += operation.get('value');
});
return this.get('initValue') + val;
}.property('[email protected]') // <- ошибка, так делать не надо
}),
operations: DS.hasMany('operation', {
async: true
})
});
export default DS.Model.extend({
initValue : DS.attr('number', { defaultValue: 0 }),
operations: DS.hasMany('operation', { async: true }),
value: function() {
var val = 0;
this.get('operations').forEach(function(operation) {
val += operation.get('value');
});
return this.get('initValue') + val;
}.property('[email protected]', 'initValue'),
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question