The following returns all active items.
activeItems: Ember.computed('items.@each.status', {
get() {
return this.get('items').filter((item) => {
return item.get('active') === 'active';
});
}
})
// Template
{{#each activeItems as |activeItems|}}
{{activeItem.status}}
{{/each}}
All of above works. Now lets say I want to create a computed property that picks out the last activeItem. I tried:
activeItem: Ember.computed('activeItems', {
get() {
return this.get('activeItems').lastObject;
}
}),
// Template
{{activeItem.status}} <-- returns nothing
Why is this and how can I get it to work?
Aucun commentaire:
Enregistrer un commentaire