ember.js - EmberJS access Ember.Object in Ember.Controller -
my purpose separate lot of boilerplate code in object, know how access object in controller.
the code looks this.
import ember 'ember'; "use strict"; var panel = ember.object.extend({ }); const person = ember.object.extend({ init() { this.set('shoppinglist', ['eggs', 'cheese']); } }); export default ember.controller.extend({ width: 0, height: 0, panel: null,
you can create object person class , assign controller properties.
arrays , objects defined directly on ember.object
shared across instances of object. when new instance created, init()
method invoked automatically. ideal place implement setup required on new instances. reference
const panel = ember.object.extend({ }); const person = ember.object.extend({ init() { this._super(...arguments); this.set('shoppinglist', ['eggs', 'cheese']); } }); export default ember.controller.extend({ width: 0, height: 0, panel: panel.create(), init(){ this._super(...arguments); this.set('person',person.create());
Comments
Post a Comment