jeudi 11 mai 2017

Ember - passing variable from route to controller

I have big trouble with EmberJS. I'm using Ember.RSVP.hash to load multiple of models like this:

route:

 model() {
    const self = this;
    return Ember.RSVP.hash({
      test: 'sample text'
    }).then((hash) => {
      return Ember.RSVP.hash({
        test: hash.test,
      });
    }, self);
  }

Then in my controller I'm trying to access this model param like this:

controller:

export default Controller.extend({
  init() {
   console.log(this.get('model.test');
  }

My console should log 'sample text' but unfortunately I'm getting 'undefined'

Is this caused by init method I used? I want to notice that I need to have access to this param immediately after loading this route page.




Aucun commentaire:

Enregistrer un commentaire