save data to local-storage in angular.js

علی ذوالفقار
1400/12/22 09:19:41 (168)
    $rootScope.save = function (key, value) {  // save to local-storage 
        localStorage[key] = angular.toJson(value);
    };

    $rootScope.load = function (key) {  // load from local-storage 
        return angular.fromJson(localStorage[key]);
    };    
Back