Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Ember from 'ember';
- export default Ember.Controller.extend({
- things: Ember.computed(() => []),
- _getId() {
- return Math.random().toString(36).slice(2, 8);
- },
- filteredThings: Ember.computed.filterBy('things', 'hasItems'),
- actions: {
- addThing() {
- const thing = Ember.Object.extend({
- hasItems: Ember.computed.notEmpty('items')
- }).create({
- title: this._getId(),
- items: Ember.A()
- });
- this.get('things').pushObject(thing);
- },
- addThingItem(thing) {
- thing.get('items').pushObject(
- this._getId()
- );
- },
- removeThingItem(thing, thingItem) {
- const items = thing.get('items');
- items.removeAt(items.indexOf(thingItem));
- }
- }
- });
Add Comment
Please, Sign In to add comment