【发布时间】:2016-03-13 05:55:23
【问题描述】:
我想使用 AngularJs 以最简单的方式从我的 Local Storage 中的某些键中访问值。 在 Resources --> Local Storage 我有:
Key:myKey
Value:{ "layouts":[ other_things ],"states":{ other_things },"storageHash":"fs4df4d51"}
我试过了:
console.log($window.localStorage.key(0).valueOf('layouts'));
//or
console.log($window.localStorage.getItem('myKey'));
结果
我的钥匙
【问题讨论】:
-
你好弗拉德,我建议使用为浏览器的 localstorage 编写的 localStorageService 模块,它有很大帮助。查看 url github.com/grevory/angular-local-storage
-
@katmanco 是的,谢谢,我看过那个模块。我想先测试一下,如果成功了,我会安装模块。
标签: javascript angularjs local-storage