mercredi 23 septembre 2015

Access controller from nested object

I need to access an ember controllers context from within a regular object. Currently I am saving a reference to the controller context in the init() method that seems a little crappy.

let self = this //saving the context here
export default Ember.controller.extend({

  init() {
    this._super(...arguments);
    self = this;
  },

  settings: {
     crud: {
        read: {
          enabled: true,
          default() {
            return self.get('blah.blah'); //Need to access the controller context
          }
        }
     }
  }

});

So I need access to the controller self.get('blah.blah'). Is there a better way to do this?




Aucun commentaire:

Enregistrer un commentaire