Angular: storage on storage
Server storage on top of Localstorage included in a module.
by Zmetser
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
Hello, {{name}}!
</div>
JavaScript
angular.module('localStorageModule', []).factory('localStorageService', function() {
console.log('localStorageService', this);
return {
log: function() {
console.log('serverStorageService::log');
}
};
});
angular.module('reportStorageModule', ['localStorageModule']).factory('reportStorageService', ['localStorageService', function(_localStorage) {
console.log('reportStorageService', this);
_localStorage.log();
return {
log: function() {
console.log('reportStorageService::log');
}
};
}]);
var myApp = angular.module('myApp', ['reportStorageModule']);
var MyCtrl = function(_scope, storage) {
_scope.name = 'Superhero';
storage.log();
};
MyCtrl.$inject = ['$scope', 'reportStorageService'];