jeudi 6 août 2015

Ember - How to add/remove elements from an array propery on controller

Given a controller in ember:

export default Ember.Controller.extend({
  stringProp: "",
  arrayProp: [],
});

You can, for example, set the string property with this.set('stringProp', "Blah blah"). But that is overriding. What I want to do is push to the array property.

Is there a better (either shorter or faster) way than this:

this.set('arrayProp', this.get('arrayProp').push(element));

Also, is there a shortcut for removing elements from such an array property?




Aucun commentaire:

Enregistrer un commentaire