storage-cookie.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. angular.module('pascalprecht.translate')
  2. /**
  3. * @ngdoc object
  4. * @name pascalprecht.translate.$translateCookieStorage
  5. * @requires $cookieStore
  6. *
  7. * @description
  8. * Abstraction layer for cookieStore. This service is used when telling angular-translate
  9. * to use cookieStore as storage.
  10. *
  11. */
  12. .factory('$translateCookieStorage', ['$cookieStore', function ($cookieStore) {
  13. var $translateCookieStorage = {
  14. /**
  15. * @ngdoc function
  16. * @name pascalprecht.translate.$translateCookieStorage#get
  17. * @methodOf pascalprecht.translate.$translateCookieStorage
  18. *
  19. * @description
  20. * Returns an item from cookieStorage by given name.
  21. *
  22. * @param {string} name Item name
  23. * @return {string} Value of item name
  24. */
  25. get: function (name) {
  26. return $cookieStore.get(name);
  27. },
  28. /**
  29. * @ngdoc function
  30. * @name pascalprecht.translate.$translateCookieStorage#set
  31. * @methodOf pascalprecht.translate.$translateCookieStorage
  32. *
  33. * @description
  34. * Sets an item in cookieStorage by given name.
  35. *
  36. * @param {string} name Item name
  37. * @param {string} value Item value
  38. */
  39. set: function (name, value) {
  40. $cookieStore.put(name, value);
  41. }
  42. };
  43. return $translateCookieStorage;
  44. }]);