删除与另一个JSON javascript angularjs-JSON匹配的JSON
delete JSON which match to another JSON javascript angularjs json
JSON A['711','722','733','744']
JSON B[{pid:711,名称:"hello"},{pid:733,名称"world"}
试着删除与JSON A匹配的数组B。就像JSON B 711、733、744与JSON A的数组匹配一样,我想删除它们。
我尝试了以下函数,但不起作用,因为它总是有一个或两个字符串是miss-delete。
angular.forEach(B, function(value, index){
if(A.indexOf(value.pid) > -1){
B.splice(index , 1);
}
});
循环通过数组A,然后使用filter函数过滤数组B并使用迭代器函数,只返回键"pid"不匹配的函数。
for(var c of A){
B = B.filter(function(n){
return n.pid !== parseInt(c)
});
}
希望这对有帮助
相关文章:
- AngularJS JSON not arriving php
- 更新嵌套json Angularjs中的对象
- 将Excel/CSV文件中的数据导入angularjs-json对象中
- AngularJS json.parse 在 json 数据的第 1 行第 1 列处意外的数据结尾
- AngularJS JSON漏洞保护是如何工作的
- javascript标记中包含变量的AngularJS JSON数组
- AngularJS - Json to Tree structure
- AngularJS Json 数组的对象
- 使用 2 个键从 JSON AngularJS 接收数据
- AngularJS JSON format
- AngularJS - jSON on date 顯示某些 ID
- Angularjs JSON treeview, json format issue
- Blueimp文件上传angularjs json前缀
- AngularJS Json Array
- 用额外的视图逻辑属性丰富angularjs-json数据
- JSON AngularJS多个对象
- 从模态窗口到JSON AngularJS
- 删除与另一个JSON javascript angularjs-JSON匹配的JSON
- AngularJS Json list
- AngularJS Json Editor