2

I am using angularjs to integrate my apis.

I have a grid table and DELETE button in each row.

my controller have following code:

$scope.singleAppDetails = {};

$scope.removeRow = function(detail, index){             

       var delRes =  $http.delete($scope.appUrl + detail.id, detail);
        delRes.success(function (data, status, headers, configs) {
            console.log(data);
        });
        delRes.error(function (data, status, headers, configs) {
            console.log(data);
        });
        $scope.singleAppDetails.splice(index, 1);
    };

and $scope.singleAppDetails contains:

Object {id: "553e20fce4b0f4eb7d13fd13", name: "Amazon", appId: "3ebc86ea-62a7-419f-9f60-dc88b66efa6e", secret: "n9prQ8YSdcxuBAcQ1PX4DUeOUBZoAKqBHnCONrueGoUTE8pqFZ", domain: "e-commerce"}

But i am getting "TypeError: $scope.singleAppDetails.splice is not a function" error in console.

mahendrakawde
  • 215
  • 3
  • 7
  • 21
  • Your question is unclear to me! What do you want to do exactly? - please share your html code that has `ng-repeat` -HTH ;). – shA.t Jan 21 '18 at 11:06

2 Answers2

0

You get that error because splice is a method for Arrays only and $scope.singleAppDetails is an object in your code.

Adrian Neatu
  • 1,989
  • 2
  • 19
  • 34
0

splice() is a Array function. See the documents.

You define singleAppDetails as an object:

$scope.singleAppDetails = {};

Answer: Delete the id with:

delete $scope.singleAppDetails.id;

See this example on JSBin.

ohboy21
  • 4,259
  • 8
  • 38
  • 66