jeudi 3 décembre 2015

can't set model attribute in a controller

I have a simple model named "test" that looks like this:

export default DS.Model.extend ({
  name: DS.attr('string')
  })

My model hook in the "test" route is defined as follows:

 export default Ember.Route.extend({
   model() {
     return this.store.createRecord('test');
     }
 });

I tried to assign an initial value to model.name in the "test" controller, but I can't get the 'set' to work.

export default Ember.Controller.extend({
  init: function() {
    let mod = this.get('model');
    this.set (mod.name, "dummyName");
    }
})

Ember inspector says mod=null. What am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire