samedi 18 juin 2016

Using a model in controller actions - Ember2.5

When trying to access the model of a controller when creating a computed property on the controller, I get the following error:

Assertion Failed: Ember.Object.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create()

app/controller/ticket.js

export default Ember.Controller.extend({
  statuses: Ember.computed('model', function() {
      var model = this.get('model');
      return model
              .uniqBy('status')
              .map(function(i) { return i.status; })
              .toArray();
  }),
});

The model I'm giving to the controller is a collection returned from this.store.findAll('ticket');, but trying to iterate through it seems to be causing the above error. Am I reading the model in the wrong way?




Aucun commentaire:

Enregistrer un commentaire