samedi 23 septembre 2017

pushobject is not a function emberjs

I've got an odd issue with ember js, when i push an object to a model. Here is my code:

// Environment.js
  EXTEND_PROTOTYPES: {
    // Prevent Ember Data from overriding Date.parse.
    Date: true,
    Array: true,
  }

Route.js

 model () {
  return Ember.RSVP.hash({
    newCollection: this.get('store').createRecord('collection'),
    book1: this.get('store').createRecord('book'),
    book2: this.get('store').createRecord('book')
  })
}

Controller

actions:{
  addCollection(model) {
    model.newCollection.pushObject(model.book1);
    model.newCollection.pushObject(model.book2);
  },
}

Now I'm not sure what the issue, but I'm trying to push the book model into the collection, however, I get an issue with this as the console log suggests that pushObject is not a function. I've updated my Environment.js as other questions have suggested, however this still is an issue.




Aucun commentaire:

Enregistrer un commentaire