如何在编辑记录时更新和删除angularjs对象中的行 [英] How to update and delete the row in angularjs object while editing the record
本文介绍了如何在编辑记录时更新和删除angularjs对象中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更新并删除角度数组对象的记录。我不知道该怎么做。我是全新工作的角度请帮忙。
我的代码如下:
i want to update and delete the record from angular array object. i don't know how to do this. i am totally new to work with angular please help.
my code is below:
//Add Employee
$scope.AddEmployee = function () {
$scope.Employee = {};
$scope.Employee.EmpName = $scope.EmpName;
$scope.Employee.Address = $scope.Address;
$http({
method: 'post',
url: 'Employee/AddEmployee',
dataType: 'json',
data: JSON.stringify($scope.Employee)
}).then(function (response) {
// $scope.GetEmployee();
$scope.Employees.push({
EmpName: response.data.EmpName,
Address: response.data.Address,
EmpId: response.data.EmpId
});
$scope.EmpName = "";
$scope.Address = "";
}, function () {
alert('Error! try again');
});
}
我尝试过:
What I have tried:
//Add Employee
$scope.AddEmployee = function () {
$scope.Employee = {};
$scope.Employee.EmpName = $scope.EmpName;
$scope.Employee.Address = $scope.Address;
$http({
method: 'post',
url: 'Employee/AddEmployee',
dataType: 'json',
data: JSON.stringify($scope.Employee)
}).then(function (response) {
// $scope.GetEmployee();
$scope.Employees.push({
EmpName: response.data.EmpName,
Address: response.data.Address,
EmpId: response.data.EmpId
});
$scope.EmpName = "";
$scope.Address = "";
}, function () {
alert('Error! try again');
});
}
i想要在编辑记录时执行此类功能,只更新特定行而不是完整数据。
i want to do this kind of functionality while edit the record, update only particular row not the complete data.
推荐答案
scope.AddEmployee = function(){
scope.AddEmployee = function () {
scope.Employee = {};
scope.Employee = {};
scope.Employee.EmpName =
scope.Employee.EmpName =
这篇关于如何在编辑记录时更新和删除angularjs对象中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文