angular local storage - AngularJs Localstorage data lost when uploading new page -


i'm working on page faqs, , i'm using angular localstorage save data. i'm uploading files server, share other people. when loose data, , it.it's first time i'm uploading, can't there. insert data, , works fine, if close browser , open again, data there.

but when upload again .html file, server, loose again. it's same url, same html page, how data in angular localstorage kind gets reseted.

i'm new @ angular, , i'm using localstorage first time. i've search issue have not found tips.

how can keep data in localstorage?

my code in angular module is:

var app = angular.module('wikicttxapp',['ngsanitize', 'ngstorage']);

app.controller('infointercontroller',function($scope, $localstorage,$sessionstorage){

    $scope.$storage = $localstorage;      $scope.infointer = $localstorage.infointer;      $scope.newinfointer = {};      $scope.addinfointer=function(){         /* ad(added later): added line test , initialize variable , issue disapeard */         if (typeof($scope.infointer) == 'undefined'){$scope.infointer=[]};          $scope.infointer.push($scope.newinfointer);         $scope.newinfointer = {};         $scope.save();     };      $scope.remove = function(item) {        var index = $scope.infointer.indexof(item);       $scope.infointer.splice(item, 1);          };      $scope.save = function() {         $localstorage.infointer = $scope.infointer;     };      $scope.load = function() {         $scope.infointer = $localstorage.infointer;     };  }); 

i've not encountered specific case, localstorage html5 feature used angular, , not feature of angular itself. therefore dependent on implementation of browser being used , users settings - not have control on whether (or how long) storage persisted.

as general rule should never assume there, , should write code handles case data not exist.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -