Angular Local Storage 使用方法
2016-08-10 11:44
253 查看
JS Example
var YourCtrl = function($scope, localStorageService, ...) { // To add to local storage localStorageService.set('localStorageKey','Add this!'); // Read that value back var value = localStorageService.get('localStorageKey'); // To remove a local storage localStorageService.remove('localStorageKey'); // Removes all local storage localStorageService.clearAll(); // You can also play with cookies the same way localStorageService.cookie.set('localStorageKey','I am a cookie value now'); }
API Access
Call | Arguments | Action | Returns |
---|---|---|---|
isSupported | n/a | Checks the browsers support for local storage | Boolean for success |
set | key, value | Adds a key-value pair to the browser local storage | Boolean for success |
get | key | Gets a value from local storage | Stored value |
remove | key, ... | Removes a key-value pairs from the browser local storage | n/a |
clearAll | n/a | Warning Removes all local storage key-value pairs for this app. It will optionally take a string, which is converted to a regular expression, and then clears keys based on that regular expression. | Boolean for success |
cookie | set | get | remove | clearAll | Each function within cookie uses the same arguments as the coresponding local storage functions | n/a |
相关文章推荐
- angular localStorage使用方法
- Thread Local Storage---__thread 关键字的使用方法
- Thread Local Storage---__thread 关键字的使用方法
- 线程本地存储(Thread Local Storage, TLS)简单分析与使用
- Spring配置文件中使用ref local与ref bean的区别. 在ApplicationResources.properties文件中,使用<ref bean>与<ref local>方法如下
- angular.foreach 循环方法使用指南
- angular.foreach 循环方法使用指南
- 线程本地存储(Thread Local Storage, TLS)分析与使用
- 移动端浏览器隐私模式/无痕模式使用本地存储localStorage/sessionStorage的问题
- 关于Parallel.For/Foreach并行方法中的localInit, body, localFinally使用
- 原生JavaScript常用本地浏览器存储方法五(LocalStorage+userData的一个浏览器兼容类)
- [并发并行]_[C/C++]_[使用线程本地存储Thread Local Storage(TLS)-win32线程和pthread线程比较]
- Spring配置文件中使用ref local与ref bean的区别. 在ApplicationResources.properties文件中,使用<ref bean>与<ref local>方法如下
- UILocalNotification本地通知的使用方法
- 使用局部二进制模型改进SIFT描述方法(Description of interest regions with local binary patterns)
- AppCan开发平台之localStorage和sessionStorage的使用
- UILocalNotification的使用方法
- JSP 使用<%@include%>报Duplicate local variable path 错误 解决方法
- JSP 中使用<%@include%> 报 Duplicate local variable path 错误的解决方法
- 线程本地存储(Thread Local Storage, TLS)简单分析与使用