define(['app'], function (app) {
  "use strict";

  return app.service('storageService', ['$window', function (win) {
      this.available = 'localStorage' in win;

      this.get = function (key) {
        return win.localStorage.getItem(key);
      };

      this.set = function (key, value) {
        return win.localStorage.setItem(key, value);
      };

      this.setJSON = function (key, value) {
        return this.set(key, win.JSON.stringify(value));
      };

      this.getJSON = function (key) {
        return win.JSON.parse(this.get(key));
      };
  }]);
});

define(['app', 'angular'], function (app, angular) {
  "use strict";

  return app.service('storageService', ['$window', function (win) {
      this.available = 'localStorage' in win;

      this.get = function (key) {
        return win.localStorage.getItem(key);
      };

      this.set = function (key, value) {
        return win.localStorage.setItem(key, value);
      };

      this.setJSON = function (key, value) {
        return this.set(key, angular.toJson(value));
      };

      this.getJSON = function (key) {
        return angular.fromJson(this.get(key));
      };
  }]);
});

Use angular's JSON lib, since it strips off $hashKey that angular adds to scope objects