Reputation: 4381
In Ember rc6 I was successfully binding a controller JobsTableColumnsController
to an attribute columns
inside of a controller JobsTableController
. The JobsTableColumnsController
would be created and bound to the columns
attribute automatically.
Here is the code that works in rc6:
App.JobsTableRoute = Ember.Route.extend
model: -> App.Job.all()
setupController: (ctlr, model) -> ctlr.set('content', model)
App.JobsTableController = App.TableController.extend
needs: ['jobsTableColumns']
columnsBinding: 'controllers.jobsTableColumns'
App.JobsTableColumnsController = App.ColumnsController.extend
content: Em.A([
App.ColumnDefinition.create(name: 'Id')
App.ColumnDefinition.create(name: 'Description')
])
In rc8 I have to explicitly set the JobsTableColumnsController
to the JobsTableController.columns
attribute in the router like so:
App.JobsTableRoute = Ember.Route.extend
model: -> App.Job.all()
setupController: (ctlr, model) ->
columns = @controllerFor('jobsTableColumns')
ctlr.set('columns', columns)
ctlr.set('content', model)
Is this a bug, or do I need to change my strategy of binding controllers to attributes using the needs
attribute.
Upvotes: 1
Views: 88
Reputation: 23322
Is this a bug, or do I need to change my strategy of binding controllers to attributes using the needs attribute.
No it's not a bug, the use of somePropertyBinding
was quietly deprecated in favor of computed properties. For reference please see the comment by Peter Wagenet here: https://github.com/emberjs/ember.js/issues/1164#issuecomment-23200023
And as for the new strategy you should use Ember.computed.alias
.
App.JobsTableController = App.TableController.extend
needs: ['jobsTableColumns']
columns: Ember.computed.alias('controllers.jobsTableColumns')
This way you don't need the extra work in the JobsTableRoute
setupController
hook.
Hope it helps.
Upvotes: 1