Francis Empleo Francis Empleo - 25 days ago 9
AngularJS Question

NgModel for a set of dynamic inputs

Problem

my problem is that i can't assign ng-model to a set of inputs that
are generated dynamically. in my previous questions,(solved already) i ask
on how to assign ng-model in "a"(meaning one) input that is dynamic.
(current problem)now, i have a set of inputs.

What i've tried

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

Answer

you can add addition property to your details array and assign it to the ng-model

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