This repository has been archived on 2020-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
angular-local-storage/demo/demo-app.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
window.angular.module('demoModule', ['LocalStorageModule'])
.config(function(localStorageServiceProvider){
2013-12-27 04:14:15 +00:00
localStorageServiceProvider.setPrefix('demoPrefix');
// localStorageServiceProvider.setStorageCookieDomain('example.com');
// localStorageServiceProvider.setStorageType('sessionStorage');
})
.controller('DemoCtrl',
2013-12-27 04:14:15 +00:00
function($scope, localStorageService) {
$scope.localStorageDemo = localStorageService.get('localStorageDemo');
2012-10-30 06:29:56 +00:00
2013-12-27 04:14:15 +00:00
$scope.$watch('localStorageDemo', function(value){
localStorageService.set('localStorageDemo',value);
2013-12-27 04:14:15 +00:00
$scope.localStorageDemoValue = localStorageService.get('localStorageDemo');
});
2013-04-10 06:49:47 +00:00
2013-12-27 04:14:15 +00:00
$scope.storageType = 'Local storage';
2013-04-10 06:49:47 +00:00
if (localStorageService.getStorageType().indexOf('session') >= 0) {
2014-05-08 06:39:55 +00:00
$scope.storageType = 'Session storage';
}
2013-12-27 04:14:15 +00:00
if (!localStorageService.isSupported) {
$scope.storageType = 'Cookie';
}
$scope.$watch(function(){
return localStorageService.get('localStorageDemo');
}, function(value){
$scope.localStorageDemo = value;
});
$scope.clearAll = localStorageService.clearAll;
2013-04-10 06:49:47 +00:00
}
);