I have stored certain information in localStorage like-

我已将某些信息存储在localStorage中 - 如

$localStorage.recent = [{'id':1,'name':'abc','is_availbale':1},{'id':2,'name':'xyz','is_availbale':1},{'id':3,'name':'pqrs','is_availbale':0}];

having another array which is only having id's of certain people like(array_second can have only those id's which are already there in $localStorage.recent)-

拥有另一个只有某些人的id的数组(array_second只能拥有$ localStorage.recent中已有的那些id) -

array_second=['3'];

I want to delete those entries from $localStorage.recent which are corresponding to the id's in array_second. Expected output to be-

我想从$ localStorage.recent中删除那些与array_second中的id相对应的条目。预期产量为 -

$localStorage.recent = [{'id':1,'name':'abc','is_availbale':1},{'id':2,'name':'xyz','is_availbale':1}];

2 个解决方案

#1


0

You're just handling a standard array. The ngstorage library doesn't give you any additional functionality here.

你只是在处理标准数组。 ngstorage库在此处不提供任何其他功能。

For example:

$localStorage.recent = $localStorage.recent.filter((person) => {
    return second_array.indexOf(person.id) !== -1;
});

更多相关文章

  1. Python 3.4:试图让这个模块对这个2d数组中的销售总数求和。不工作
  2. Python:2D Numpy数组(矩阵) - 查找负数之和(行)
  3. 如何在Python Django中附加数组字段
  4. 找到多维Python数组的维度[重复]
  5. 剑指offer python版 数组中只出现一次的两个数字
  6. 数组与矩阵---需要排序的最短子数组长度
  7. 在NumPy中更改数组边缘的值
  8. 将muilti维Json数组解析为Python
  9. python 中 字符串转换为数组,字典或表达式

随机推荐

  1. 如何在PHP 5.4.33 Apache服务器上启用mbs
  2. 解析错误:语法错误,E:\xampp\htdocs\on
  3. 访问控制允许原点 - 不工作
  4. 如何使用ChromePhp Logger记录数组
  5. 最佳做法,PHP,每天跟踪数百万次展示
  6. 使用PHP和MySQL开发“测试”Web应用程序
  7. 如何获取关联数组的当前元素数?
  8. 如何使用PHP读取.xls文件(Excel) ?
  9. 在返回按钮上重新加载页面。
  10. php微信网页授权获取用户信息