I have a set of JSON data returned by the backend API, and i need to loop through existing array and get the index to be used in splice, thus i am using indexOf method combined with the filter function from angular.
I am able to filter the data out from existing array, however i am unable to get the index of the array, it returned -1.
This is how do it.
JS
angular.forEach($scope.data, function(){
var index = $scope.Tablelist.indexOf($filter('filter')($scope.Tablelist,{id: $scope.data.id},true));
console.log($filter('filter')($scope.Tablelist,{id: $scope.data.id},true));
console.log(index);
})