【发布时间】:2017-09-24 00:57:18
【问题描述】:
这是我目前想要在我的组件中做的事情。每当我路由到不同的组件时,我都想删除或销毁我的 localStorage 内容。我想实现这一点,以避免 localStorage 变量存储以前的值,即使有新值进来。我在正确的道路上吗?
游戏组件
export class Game implements OnDestroy{
constructor(){
this.currentGame = JSON.parse(localStorage.getItem('currentGame'));
}
ngOnDestroy(){
this.currentGame = null;
}
}
【问题讨论】:
标签: angular local-storage