Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between ngStorage and $window.localStorage

What is the difference between ngStorage and $window.localStorage? When is it better to use one instead that the other? I have to choose one of them for a web app. I have to save data of profile user and the token

like image 596
panagulis72 Avatar asked Apr 14 '16 15:04

panagulis72


Video Answer


1 Answers

Just be mindful ngStorage internally uses an Angular watch to monitor changes to the $storage/$localStorage objects i.e a digest cycle is required to persist your new values reliably into the browser's local storage. Normally not a problem but if you store a value in $localStorage and open a new tab without a digest cycle occurring, you might not be able to see the stored values in your newly opened tab/window.

Ran into this problem on IE and had to use window.localStorage to get around it.

like image 190
Kanban Avatar answered Oct 23 '22 21:10

Kanban