角动态ng-模型名称

时间:2015-02-23 05:23:52

标签: javascript angularjs angularjs-ng-model angularjs-forms

<div class="pw-form-control-text" id="disclosureQuestionsPrepopulate" name="disclosureQuestionsPrepopulate"  ng-repeat="type in (prepopulatingFieldData|prepopulateValue:'c2a39346-9e95-e411-bd87-00155d005107')" >

<div >
<input name="{{type.Id}}" ng-model="formData.disclosureQuestionsPrepopulate"($index + 1) ng-click="option.selected = true" type="radio" value=true >Yes</input>

</input>

    

这里我要做的是我的ng-model名称应该是这样的

  

formData.disclosureQuestionsPrepopulate1" ,   formData.disclosureQuestionsPrepopulate2

像这样,但它不起作用。 有人能帮助我吗?

1 个答案:

答案 0 :(得分:2)

应使用[]ng-model变量&amp;分配创建数组Value属性也应为ng-value,以确保与复选框绑定

<强> HTML

<input ng-attr-name="{{type.Id}}" 
ng-model="formData['disclosureQuestionsPrepopulate'+($index + 1)]" 
ng-click="option.selected = true" type="radio" ng-value="true"/>Yes