DraganS
DraganS

Reputation: 2699

View helper - how to use controllerBinding

I have to show the 'coach' field from IndexController transformed by AController:

{{!view App.AView coach | A }}

To get the result I've used the workaround:

{{! aList = [coach] }}
{{#each a in aList itemController = "A"}}
    {{view App.AView controllerBinding = "a"}} 
{{/each}}

The view A cannot directly render data from the coach field. The field should be decorated by AController.

I would appreciate any help or guidance:)

http://jsfiddle.net/6Evrq/513/

Upvotes: 0

Views: 37

Answers (1)

blessanm86
blessanm86

Reputation: 31779

You will need to specify the controller for the view when its initialised. The code will look like

App.AView = Ember.View.extend({
  templateName: 'a-a',
  setup:function() {
    this.set("controller", App.AController.create({
      model:this.get("controller.aList")
    }));
  }.on('init')
});

Here is a link to the working demo.

Upvotes: 1

Related Questions