简体   繁体   English

如何在Angularjs中为不同用户提供唯一的本地存储变量

[英]How to have a unique local storage variable for different users in Angularjs

I'm building an app using ionic framework. 我正在使用离子框架构建应用程序。 I have an array that i store locally using ngStorage... my problem when i logout i have to clear the $localStorage.SomeArray so that the when logged in as a different user, that user won't inherit the $localStorage.SomeArray. 我有一个使用ngStorage在本地存储的数组...退出时的问题是我必须清除$ localStorage.SomeArray,以便以其他用户身份登录时,该用户不会继承$ localStorage.SomeArray。 Is there a way to that 有办法吗

How to have a unique local storage variable for different users in Angularjs 如何在Angularjs中为不同用户提供唯一的本地存储变量

Store it under some user-specific key, eg: 将其存储在特定于用户的密钥下,例如:

localStorage[userKey] = [/*...the array...*/];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM