Angular dynamic ng-model name

2019-09-01 07:44发布

<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>

here what I want to do is my ng-model name should be like this

formData.disclosureQuestionsPrepopulate1", formData.disclosureQuestionsPrepopulate2

like that but it doesnt work. Can someone help me?

1条回答
看我几分像从前
2楼-- · 2019-09-01 08:41

It should use [] to assign create a array for ng-model variable & also Value attribute should be ng-value to ensure binding with check box

HTML

<input ng-attr-name="{{type.Id}}" 
ng-model="formData['disclosureQuestionsPrepopulate'+($index + 1)]" 
ng-click="option.selected = true" type="radio" ng-value="true"/>Yes
查看更多
登录 后发表回答