vendredi 7 août 2015

Ember get inconsistent behavior

I find an inconsistent behavior of Ember.get on refreshing events (Ember.run loop for observers/computed properties). I have a child controller that tries getting model of its parent controller:

App.ParentChildController = Ember.Controller.extend({
   parent: Ember.inject.controller(),
   anObserver: function(){
      var someRelation = this.get('parent.model.someRelation'); // problem line
   }.observes('someProperty').on('init') 
});

It works on the controller initialisation. But on the parent refresh it raises an error:

TypeError: this.get(...) is undefined

someRelation is an async relation that has already been resolved. So if I put a breakpoint on the problem line the following works:

this.get('parent.model').get('someRelation');

What is going wrong?




Aucun commentaire:

Enregistrer un commentaire