angular-webstorage icon indicating copy to clipboard operation
angular-webstorage copied to clipboard

How to specify the order in my app config?

Open stonehz opened this issue 13 years ago • 3 comments

I am trying to set the order of the storage. Is there a way to do it as part of the angular app.config?

Example

var App = angular.module('App', ['webStorageModule']);
App.config(function ($routeProvider, webStorage, $httpProvider) {
  webStorage.order('local', 'session', 'memory');
});


stonehz avatar Oct 31 '13 16:10 stonehz

Great idea! I have added functionality for this in version v0.10.2.

fredricrylander avatar Dec 19 '13 09:12 fredricrylander

After sifting through the AngularJS docs regarding $provide (http://docs.angularjs.org/api/AUTO.$provide), I'm adding a heads up for the code specified above.

It turns out you cannot inject services (created via factories, as is webStorage) into your app’s configuration function, but you may instead setup webStorage in your app’s run function, e.g.:

var App = angular.module('App', ['webStorageModule']);
App.run(function (webStorage) {
    webStorage.order('session', 'local', 'memory');
});

fredricrylander avatar Dec 19 '13 10:12 fredricrylander

Thanks a lot!

stonehz avatar Dec 19 '13 12:12 stonehz