-1

In Angularjs, it will refresh the page each time I come into a new page.

Now in Page1, I have already opened a modal dialog and written some texts in it, then I click a button it redirect to Page2.

There's a link now in the header like : Page1 -> Page2.

When I click Page1 of the link, it will return to Page1 with all former data kept(modal is opening, data is still there...)

How to accomplish system page state cache in angularJS?

halfer
  • 19,824
  • 17
  • 99
  • 186
Ryan
  • 19,118
  • 10
  • 37
  • 53

1 Answers1

0

You need to store the page state somewhere. Most sites are using SessionStorage or LocalStorage.

Everytime you change your page state you have to update your storage. On a page reload you need to check your storage whether there is any state saved and load it before any other interaction.

The easyiest way may be a angular plugin like https://github.com/gsklee/ngStorage or https://github.com/grevory/angular-local-storage

Sven 31415
  • 1,775
  • 1
  • 25
  • 33
  • Thanks, it is very helpful.Since localstorage is page cache, my boss does not want it.How about memory cache?How to do it then... – Ryan Jul 13 '20 at 08:21