lundi 21 mai 2018

Ember.JS data model: Filtering a computed property

I have an Ember data model logger defined as below:

import DS from 'ember-data';
import EmberObject, { computed } from '@ember/object';
export default DS.Model.extend({

    someAttribute: DS.hasMany('attr'),
    test: computed('someAttribute.[]', function(){
        return this.get('someAttribute').filterBy('description', 'some value');        
    })
});

The above model gets passed as logger variable from the controller into my component template. In my template:

    
    <h1> Testing </h1>
    


It seems like the logger.test in the template is always false. In the same template if I add the following:


    


I can see all the values being enumerated. Not sure what I am missing? Any assistance would be greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire