jeudi 16 février 2017

In Ember JS using the get and set functions

In Ember JS any Ember object you can call

this.get('model');

or

this.get('changeset');

On several current examples I've seen the following syntax.

const { get } = Ember;

export default Component.extend({

   init() {
       this._super(...arguments);
       let model = get(this, 'model');
       // Do something to a model
   }
});

Why would you use this style rather than

this.get('model');




Aucun commentaire:

Enregistrer un commentaire