首页 > 解决方案 > 以离子角度获取存储项目

问题描述

我想知道如何通过 angular 从 ionic 中的存储中获取特定项目。

逻辑

这就是我在本地存储中的内容

item {
  {id: 1, title: xxxx, url: xxxx},
  {id: 2, title: xxxx, url: xxxx},
  {id: 3, title: xxxx, url: xxxx},
};

我需要获得特定的项目,例如:

data {
  id: 1, title: xxxx, url: xxxx
}

代码

module

getDetails(url) {
    return this.storage.getItem('item').then((data: any) => {
      this.post.push(data);
    });
}

view

[routerLink]="['/', 'posts', post.url]"

更新

我在控制台中的数据如下:

在此处输入图像描述

标签: angularionic-framework

解决方案


推荐阅读