Skip to content

Instantly share code, notes, and snippets.

@eccegordo
Last active December 20, 2015 19:09
Show Gist options
  • Save eccegordo/6180740 to your computer and use it in GitHub Desktop.
Save eccegordo/6180740 to your computer and use it in GitHub Desktop.
Controller with generic array and events
App.FoosController = Ember.ArrayController.extend({
myOptions: Ember.A([]),
addOptionItem: function(option) {
this.pushObject(option);
},
removeOptionItem: function(option) {
this.get('myOptions').forEach(function(item, i, myOptions) {
if (item.get('id') === option.get('id')) {
myOptions.removeAt(i, 1);
}
});
},
resetOptions: function() {
this.set('myOptions', []);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment