我正在使用angularjs来集成我的apis。如何从angularjs中的json对象中删除元素
我在每一行都有一个网格表和DELETE按钮。
我的控制器有如下代码:
$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);
};
和$ scope.singleAppDetails包含:
Object {id: "553e20fce4b0f4eb7d13fd13", name: "Amazon", appId: "3ebc86ea-62a7-419f-9f60-dc88b66efa6e", secret: "n9prQ8YSdcxuBAcQ1PX4DUeOUBZoAKqBHnCONrueGoUTE8pqFZ", domain: "e-commerce"}
但我得到 “类型错误:$ scope.singleAppDetails.splice不是一个函数” 在控制台中出错。
你的问题对我来说还不清楚!你想要做什么? - 请分享你的具有'ng-repeat' -HTH;的HTML代码)。 –