So I have a model in my ember application that looks like this:
import DS from 'ember-data';
export default DS.Model.extend({
title: DS.attr("string"),
highscore: DS.attr("number"),
type: DS.attr("string"),
choices: DS.hasMany("word-part"),
usedChoices: DS.hasMany("word-part"),
controller: DS.attr("string", {defaultValue: "activity"})
});
And I need to be able to pop items out of the choices
array, but it seems it's not a mutable array. I've been looking over the docs and I can't find a way to have choices
resolve as a MutableArray
. Is there something I'm missing here? It appears the choices
property of resolved models is readonly, so I can't even overwrite the entire array.
Any help would be greatly appreciated.
If you have your model
and choice
and you know which choice, you would do this:
model.choices.removeObject(choice);
hasMany
implements everything on Ember.MutableArray
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.