angular-webstorage
angular-webstorage copied to clipboard
How to specify the order in my app config?
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');
});
Great idea! I have added functionality for this in version v0.10.2.
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');
});
Thanks a lot!