-1

I would like to cache some data and I read about Cache Factory, which just caches the data for the current session. But I want to keep my data in cache even after the page was reopened. What is be a better way do that?

Oleksandr Pyrohov
  • 14,685
  • 6
  • 61
  • 90
  • sounds like you want localStorage. Question is not clear though as to exactly what you are wanting to do. In english `until browser wasn't closed` doesn't make sense and I think might be a translation problem – charlietfl Jul 29 '15 at 13:23

2 Answers2

2

I think i understand what you're asking here...

If you're trying to keep the data for the current "local session" try using a service/factory, and just store the data in a local variable and create getters and setters for that.

Since the local variable isn't persisted it will be lost when the current local "session" is destroyed (i.e the user refreshes, or closes the window)

Similar to this answer: https://stackoverflow.com/a/14959540/2803660

Community
  • 1
  • 1
MrHaze
  • 3,786
  • 3
  • 26
  • 47
2

You can use LocalStorage, sessionStorage or $cookies service :

https://docs.angularjs.org/api/ngCookies/service/$cookieStore

Siddharth
  • 6,966
  • 2
  • 19
  • 34