angular localStorage使用方法

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');
}個人angular實例localStorage.setItem('localStorageKey','Example');var sign = localStorage.getItem('localStorageKey');alert(sign);
相關文章
相關標籤/搜索