RaV RaV - 5 months ago 11x
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.


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 = [];