0
我有一個動態的形式,接收與顯示字段的jsons數組。我的問題是在ng-model
和NG-要求他們在陣列中,無法得到的價值是在ng-model
名ng變量名稱與變量
這是我的代碼:
包含數據
form_array : [
{label: "Responsable", name: "dynamic", required: true},
{label: "Username", name: "user1", required: true},
{label: "Number", name: "user2", required: false},
{label: "Age", name: "user3", required: false}
]
形式
HTML顯示錶單字段
<form name="form" class="form-submit">
<div class="form-group">
<div ng-repeat="fa in form_array ">
<label>{{fa.label}} {{fa.name}} {{fa.required}}</label> <input class="form-control" type="text"
ng-model="requestForm.{{fa.name}}" ng-required={{fa.required}}></div>
</div>
<button id="resetbtn" class="btn btn-primary" type="reset" value="Reset">Limpar</button>
<button id="sendReport" class="btn btn-primary" ng-disabled="requestForm.$invalid"
ng-click="send(form)">
犯規得到變量名,香港專業教育學院試過了。我需要'ng-model = requestForm.name' – changez
@changez hm,也許'requestForm [{{fa.name}}]' – user2954587
請在答案中添加一些細節,以便OP和未來的讀者都能受益與建議的解決方案背後的原理 –