Click here to Skip to main content
14,661,076 members
Rate this:
Please Sign up or sign in to vote.
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100