2016-11-11 57 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

感谢这个想法。 –