RaV RaV - 1 year ago 94
Javascript Question

Restoring form from LocalStorage when page refresh

<div ng-repeat="filterSection in filterSections">
<h4>{{ filterSection.title }}</h4>
<div class="checkbox" ng-click="loaderStart()" ng-if="filterSection.control == 'checkbox'" ng-repeat="option in filterSection.options">
<input type="checkbox" ng-model="searchParameters[filterSection.key][option.key]" value="{{ option.key }}" checked><span></span> {{ option.value }}

I can access it with

I can store it using
localStorage.setItem('search', JSON.stringify(cleanedParameters));

I can access store with

But I have no idea how could I restore it when page refresh. Is there some function or example of directive which I could use? I couldn't really find anything similar to my problem.

Answer Source

You can try as shown below.Just create an array and push the values into that.Then you can access that array values as you wish through a loop.

var a = [];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download