Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. module storage {
  2.  
  3. export class Storage {
  4.  
  5. public static $inject = [
  6. '$window'
  7. ]
  8.  
  9. constructor(private $window: angular.IWindowService) {
  10. }
  11.  
  12. public get(key) {
  13. return JSON.parse(this.$window.localStorage.getItem(key));
  14. }
  15.  
  16. public save(key, data) {
  17. this.$window.localStorage.setItem(key, JSON.stringify(data));
  18. }
  19.  
  20. public remove(key) {
  21. this.$window.localStorage.removeItem(key);
  22. }
  23.  
  24. public clearAll() {
  25. this.$window.localStorage.clear();
  26. }
  27.  
  28. }
  29.  
  30. }
  31.  
  32. angular.module('storage').service('storage.Storage', storage.Storage);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement