Javascript 获取ng repeat Angular JS中的更新值
我使用的是ng repeat,它从我的数据库中获取值并将其放入。现在,我将这些值插入到更新的输入文本中。现在我有一个保存按钮,它保存更新的值。当我按下保存按钮时,我没有得到更新的值。请引导我通过这个Javascript 获取ng repeat Angular JS中的更新值,javascript,angularjs,angularjs-ng-repeat,ng-repeat,Javascript,Angularjs,Angularjs Ng Repeat,Ng Repeat,我使用的是ng repeat,它从我的数据库中获取值并将其放入。现在,我将这些值插入到更新的输入文本中。现在我有一个保存按钮,它保存更新的值。当我按下保存按钮时,我没有得到更新的值。请引导我通过这个 <div ng-controller="education" ng-init="getEducationDetails();"> <div class="col-md-12"> <div class="row" ng-re
<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>
以下是我的控制器方法:
$scope.educationSave = function() {
var educationArray = JSON.stringify($scope.education);
//I then save this educationArray
};
问题是您没有使用
ng model
将实际输入值绑定到控制器。发件人:
HTML输入元素控件。与ngModel一起使用时,它提供数据绑定、输入状态控制和验证
在标记中为每个输入尝试以下操作:
<input type="text" id="educationDegree" name="educationDegree"
ng-model="values.education_degree" style="width: 90%;" />
请参见littleHi@Stealz我建议您使用NgGrid进行此用途,它有一个按需编辑焦点单元格选择属性。[链接]()绝对有效。实际上,我对Angular还不熟悉,我正在学习数据绑定。谢谢
<input type="text" id="educationDegree" name="educationDegree"
ng-model="values.education_degree" style="width: 90%;" />