在 ng-repeat Angular JS 中获取更新值

Getting updated values in ng-repeat Angular JS

我正在使用 ng-repeat,它从我的数据库中获取值并将其放入。现在我将这些值插入到我更新的输入文本中。现在我有一个保存按钮,用于保存更新的值。当我按下保存按钮时,我没有得到更新的值。请指导我完成这个。

<div ng-controller="education" ng-init="getEducationDetails();">
    <div class="col-md-12">
                    <div class="row" ng-repeat="values in education"
                        style="margin-left: 20px; margin-right: 20px; margin-top: 10px;">
                        <div class="col-md-6">
                            <h4>
                                <small>Degree</small>
                            </h4>
                            <input type="text" id="educationDegree" name="educationDegree"
                                value="{{values.education_degree}}" style="width: 90%;" />
                        </div>
                        <div class="col-md-6">
                            <h4>
                                <small>Year</small>
                            </h4>
                            <input type="text" id="educationYear" name="educationYear"
                                value="{{values.education_year}}" style="width: 100%;" />
                        </div>
                        <div class="col-md-12" style="margin-top: 10px;">
                            <h4>
                                <small>University</small>
                            </h4>
                            <input type="text" id="educationUniversity"
                                name="educationUniversity"
                                value="{{values.education_university}}" style="width: 100%;" />
                        </div>
                    </div>
                </div>
                <div class="col-md-12" style="margin: 20px;">
                    <button ng-click="educationSave();" class="btn btn-default">Save</button>
                </div>
</div>

educationSave() 我保存了这些值。但是当我在 educationSave() 方法中获取教育数组时,我得到了旧数组。在我调整了一些输入类型后,我怎样才能得到更新的数组

这是我获取值的方式:

$scope.getEducationDetails = function()
            {
                $http({
                    method : 'GET',
                    url : '/getEducationDetails'
                }).success(function(data, status, headers, config) {
                        $scope.education = data.resultSet;
                        alert($scope.education);
                }).error(function(data, status, headers, config) {
                });
            };

这是我的控制器方法:

    $scope.educationSave = function() {
        var educationArray = JSON.stringify($scope.education);
        //I then save this educationArray
    };

问题是您没有使用 ng-model 将您的实际输入值绑定到控制器。来自 documentation:

HTML input element control. When used together with ngModel, it provides data-binding, input state control, and validation.

在每个 input:

的标记中尝试类似的内容
<input type="text" id="educationDegree" name="educationDegree"
                            ng-model="values.education_degree" style="width: 90%;" />

见少Demo