您的代碼將用於複選框。
{{input type="checkbox" name="customerFacing" checked=report.customerFacing value=report.customerFacing id="customerFacingYes" on-change=(action (mut report.customerFacingChange) checked)}}
<label for="customerFacingYes">{{report.customerFacing}}</label>
但單選按鈕,你可以嘗試的插件。(https://github.com/yapplabs/ember-radio-button)
ember install ember-radio-button
{{#radio-button value=report.customerFacing groupValue=report.customerFacing class="cpntr" changed=(action "customerFacingChange")}}
<label for="customerFacingYes">{{report.customerFacing}}</label>
{{/radio-button}}
在控制器或在其他任何地方,
actions: {
customerFacingChange(newValue){
console.log('Changed value'+newValue); //you can do other stuff here.
}
}
你必須創建一個自定義組件,請在這裏檢查http://stackoverflow.com/questions/30244040/recording-values-of-radio-buttons-in-ember –