M
M
Marcuzy2014-05-06 16:02:03
Angular
Marcuzy, 2014-05-06 16:02:03

Why in Angularjs ng-value doesn't fire after input in input?

Hello.
There is the following code, which displays a student progress table:

<tr ng-repeat="student in groupServ.students | reverse"  ng-class="{warning : student.updated, dim: student.deleted, success: student.created, danger: student.error}" data-id="{{student._id}}">
    <td><input type="text" ng-value="student.name" 
            class="student-name" placeholder="Имя студента" 
            on-change="studentNameOnChange" ng-disabled="student.deleted"></td>
    <td ng-repeat="subject in groupServ.subjects track by $index">
        <input type="text" class="rating-cell" ng-value="student.rating[selectedCtrlPoint][$index]" ng-disabled="student.deleted" on-change="studentRatingOnChange">
    </td>
    <td class="td-buttons">
        <button class="btn btn-sm btn-danger"  click="deleteStudent" ng-hide="student.deleted">Удалить</button>
        <button class="btn  btn-sm btn-primary"  click="restoreStudent" ng-hide="!student.deleted">Восстановить</button>
    </td>
</tr>

Problem:
Here
<input type="text" class="rating-cell" ng-value="student.rating[selectedCtrlPoint][$index]" ng-disabled="student.deleted" on-change="studentRatingOnChange">

when changing the value of selectedCtrlPoint (session number) using the ng-value directive, the values ​​of the inputs change. They change without wrangling, but if you make changes to the input from the keyboard, then with the next changes to selectedCtrlPoint, these inputs do not change (the entered value remains), everything is fine with the rest (not changed).
Why does angular behave like this? Maybe I made a mistake in something and do not understand something?
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maxaon, 2014-05-07
@maxaon

It seems you don't need ' ngValue ' which is used for select and radio, but ' ngModel '

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question