I lost a lot of time trying to delete a item from Json file
This is my json file
{
"count": 3,
"data": [
{
"id": "1",
"raison": "ABS",
"email": "[email protected]",
"tel": "021269999999"
},
{
"id": "3",
"raison": "PODL",
"email": "[email protected]",
"tel": "021269999999"
}, {
"id": "5",
"raison": "dDMS",
"email": "[email protected]",
"tel": "021269999999"
}
]
}
in controller I have like this
$scope.deleteRow = function() {
var _id = 3;
$scope.datas = JSON.stringify($scope.clients["data"]);
$scope.datas.splice(_id,1);
};
so i gave _id that i want to remove but i get this error $scope.datas.splice splice not a function, i tried a simple file it worked fine ["aaa","bob,"ccc"]
using indexof()
and splice but in this file json non :(
How in javascript can Know/compare the right id ?
so anyone help me , and thanks a lot .