1

Handle Bars Is below :- {{#each category in controller}}

 {{view Ember.Select
    contentBinding="App.testsController.content"
    optionLabelPath="content.category"

    selectionBinding="content.myVal"

 }}    

{{view Ember.Select
   contentBinding="App.testsController.content"

   optionLabelPath="content.type"  
}}   

{{view Ember.Select
   contentBinding="App.testsController.content"      
   selectionBinding="content.myVal"
}} 

controller is :-
App.TestsController = Ember.ArrayController.extend({
  content: []
});

model is :- 
App.Test = Ember.Object.extend(
 category: null
 type: null
 #operands: null
#defaults: null
)

In the view I'm not able to get the value category and type. It is not displaying. How to fix the problem?

Coral Doe
  • 1,925
  • 3
  • 19
  • 36
Amartya
  • 11
  • 2
  • Pleas read the doc here along with the code. https://github.com/emberjs/ember.js/blob/master/packages/ember-handlebars/lib/controls/select.js I have added a relevant part below – sabithpocker Sep 20 '12 at 18:13

2 Answers2

2

Are you grabbing your controller through a router? If so, you may specifically need to call contentBinding: 'App.router.testsController.content'

Also, your selectionBinding should read 'controller.myVal' instead of 'content.myVal'.

tygirl76
  • 86
  • 4
1

Please refer to Git hub doc , below is a relevant part.

Alternatively, you can control selection through the underlying objects used to render each object providing a selectionBinding. When the selected <option> is changed, the property path provided to selectionBinding will be updated to match the content object of the rendered <option> element:

App.controller = Ember.Object.create({
selectedPerson: null,
content: [
Ember.Object.create({firstName: "Yehuda", id: 1}),
Ember.Object.create({firstName: "Tom", id: 2})
]
});

{{view Ember.Select
contentBinding="App.controller.content"
optionValuePath="content.id"
optionLabelPath="content.firstName"
selectionBinding="App.controller.selectedPerson"}}

Would result in the following HTML with a selected option:

<select class="ember-select">
<option value>Please Select</option>
<option value="1">Yehuda</option>
<option value="2" selected="selected">Tom</option>
</select>
sabithpocker
  • 15,274
  • 1
  • 42
  • 75