Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

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 want to do this kind of functionality while edit the record, update only particular row not the complete data.
Posted
Updated 2-Apr-17 12:15pm

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900