2016-11-11 94 views
0

問題NgModel一組動態輸入

我的問題是,我不能NG-模型分配給 是動態生成的一組輸入。在我以前的問題中,(已解決),我問 如何在「a」(意思是一個)動態輸入中指定ng-model。 (當前問題)現在,我有一組輸入。

我已經試過

Set 1 
<input type="number" min="1" ng-model="grades[$index]" > 
<input type="number" min="1" ng-model="grades[$index]" > 
<input type="number" min="1" ng-model="grades[$index]" > 
Set 2 
<input type="number" min="1" ng-model="grades[$index]" > 
<input type="number" min="1" ng-model="grades[$index]" > 
<input type="number" min="1" ng-model="grades[$index]" > 
... so on until the last set 

Check this plunk

+0

可能的複製[在嵌套的ng-repeat指令中使用ng-model](http://stackoverflow.com/questions/15973985/using-ng-model-within-nested-ng-repeat-directives ) – georgeawg

回答

1

可以除了屬性添加到您的詳細信息陣列,並將其分配到NG-模型

"details": [{ 
    "answerid": "1", 
    "questionid": "32", 
    "question": "GFDS", 
    "pi": "P1", 
    "answer": "jyhgf", 
    "val": "" 
}] 

    <li id="student-eval">Evaluation Score: &nbsp;&nbsp;&nbsp;<input type="number" min="1" ng-model="answer.val" ></li> 
+0

感謝這個想法。 –