onsa
12/17/2016 - 12:32 AM

Example usage of ngStorage (https://github.com/gsklee/ngStorage) (localstorage is permanent in the browser, sessionstorage is destroyed when

Example usage of ngStorage (https://github.com/gsklee/ngStorage) (localstorage is permanent in the browser, sessionstorage is destroyed when browser window is closed)

//	1st: install, load file and inject module in the main app
angular.module('appName', ['ngStorage']).config(/*...*/);

//	2nd: save some data in a Controller
$localStorage. OR $sessionStorage.someData = someData;

//	3rd: retrieve data in another Controller
$scope.someData = $localStorage. OR $sessionStorage.someData;

//	4th: delete data if not needed anymore
delete $localStorage. OR $sessionStorage.someData;