2015-02-23 58 views
0
<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-型號名稱

這裏就是我想要做的就是我的NG-型號名稱應該是這樣的

formData.disclosureQuestionsPrepopulate1" , formData.disclosureQuestionsPrepopulate2

那樣但它不起作用。 有人可以幫我嗎?

+0

的可能重複的結合[如何動態地生成ng-model =「my \ _ {{$ index}}」在AngularJS中用ng-repeat?](http://stackoverflow.com/questions/19573001/how-to-generates-dynamically-ng-model-my-指數與-NG-重複功能於angularj) – squiroid 2015-02-23 05:40:48

回答

2

它應該使用[]分配創建ng-model可變&也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