controller
angular.module(‘starter’)
.factory(’$localstorage’, [’$window’, function ($window) {
return {
set: function (key, value) {
$window.localStorage[key] = value;
},
get: function (key, defaultValue) {
return $window.localStorage[key] || defaultValue;
},
setObject: function (key, value) {
$window.localStorage[key] = JSON.stringify(value);
},
getObject: function (key) {
return JSON.parse($window.localStorage[key] || ‘{}’);
},
remove: function(key) {
$window.localStorage.removeItem(key);
}
}
}]);
login.js
.controller(‘loginCtrl’, [’$scope’, ‘$http’, ‘$ionicPopup’,’$window’, ‘$localstorage’, function($scope, $http, $ionicPopup, $window, $localstorage) {
$scope.user = {};
$scope.login= function() {
$localstorage.setObject("val1", "1234");
console.log($localstorage.getObject("val1"));
}
$scope.logout = function(){
$localstorage.remove("val1")
console.log("logout");
}
session remove not working…
Your prompt reply will be much appreciated