【发布时间】:2018-05-26 23:50:08
【问题描述】:
我是 Ionic 应用程序开发的新手,我一直在学习相同的教程。
我一直在尝试使用IonicStorageModule,但即使在 chrome 浏览器移动视图模式下运行应用程序时没有错误,也不会生成本地存储密钥。
在我的app.module.ts,我有
import { IonicStorageModule } from '@ionic/storage';
然后我在imports数组中有以下导入,
imports: [
BrowserModule,
HttpModule,
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],
现在,我创建了一个服务,命名为user-settings.service.ts,
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
@Injectable()
export class UserSettings {
constructor(private storage:Storage){}
favoriteTeam(team,tournamentId, tournamentName) {
debugger;
let item = { team: team,tournamentId : tournamentId, tournamentName : tournamentName};
this.storage.set('teamId' , item);
}
unFavoriteTeam(team) {
this.storage.remove(team.id);
}
isFavoriteTeam(team) {
return this.storage.get(team.id).then(value => value ? true : false);
}
}
当我这样做时,从我的组件类中......
}else {
this.isFollowing = true;
this.userSettings.favoriteTeam(this.team,this.currentTournamentData.tournament.id,this.currentTournamentData.tournament.name);
}
即使服务被击中,我也看不到在 chrome application -> storage -> local storage. 中创建 local stoarge 键
我做错了什么?
【问题讨论】:
-
检查你使用的是mac而不是隐私浏览模式?
-
@DeepakJha 不是隐私浏览模式,但我肯定在使用 mac。
-
好吧,我曾经遇到过同样的问题,实际上苹果云不允许存储来自网络的任何内容,但我还记得当时我遇到了一个错误,显示为“达到最大堆栈大小”我可能在我的错误陈述中是不正确的,但它接近那个。如果允许您将系统中的任何内容存储在 applecloud 中,我建议您也搜索此选项。
标签: angular typescript ionic2 ionic3