lundi 1 février 2016

How to create list from model's object properties?

I have a model:

var Project = DS.Model.extend({
  title:                DS.attr('string'),
  description:          DS.attr('string'),
  full_description:     DS.attr('string'),
  category:             DS.attr('string')
});

and I try to create a list that contains only category properties of all project instances in a model. And I try to do this in the following way, as a property on a controller:

  projectTitles: Ember.computed('model', function() {
    var projects = this.get('model');
    return project.map((project) => {
      return project.category;
    });
  })

But it doesn't work and due to small experience I can't figure out why. I need some help.




Aucun commentaire:

Enregistrer un commentaire