In Ember you can dynamically lookup controllers with {{#each}}
doing something like this according to the guides:
Template:
{{#each controller}}
{{name}}
{{/each}}
Array controller:
App.DocumentListController = Ember.ArrayController.extend
lookupItemController: ((object) ->
if @get('name') == 'something' then 'someController'
else 'someOtherController'
I have a situation where I want to do the same thing but I need to use an ObjectController instead of an ArrayController.
So my template would look more like this:
{{#each controller in controller.documents itemController=lookupItemController}}
{{name}}
{{/each}}
Object controller:
App.DocumentListController = Ember.ObjectController.extend
lookupItemController: (object) ->
if @get('name') == 'something' then 'someController'
else 'someOtherController'
This second example is just made up and doesn't work. Is there a way to dynamically set controllers like this in an {{#each}}
? Is there a better way to accomplish this?