ember.js - Retrieving model's property in controller -
i have model contains single data it's inside array. want retrieve data inside controller , making property of controller can use in other controllers. example :
app.currentsubusercontroller = ember.arraycontroller.extend({ currentsubuser: function() { return this.get('model'); <-------** not working ** }.property() }); basically want whole associated model can access it's datas. syntax have use? thank you
i'm not 100% sure of goal here, controller can someattribute: ember.computed.alias('controllers.somecontroller.model')
there no need create local attribute in controller being provided model data unless transforming in way.
you need specify needs in controller reference 1 pulling model data (adjust global style javascript)
export default ember.controller.extend({ needs: ['somecontroller'], someattr: ember.computed.alias('controllers.somecontroller.model') }) i know work fine, thats not should doing of this. and, obviously, make sure model data in originating controller expect. quick way validate tossing logging helper handlebars {{log model}} or using ember inspector in browser.
update: based on comment below, work
export default ember.controller.extend({ currentsubuser: ember.computed.readonly('model.firstobject'), }) then, in template can use {{ currentsubuser.foo }}
Comments
Post a Comment