[Angular 2] Anyone know of good resources on using Local Storage with Angular 2?

I can’t find anything from Googling other than someone’s open source module they built to scaffold over top of the in-built local storage feature in ng2.

I can’t even find anything in the API Reference at angular.io.

Thanks @P1xt, the angular2-storage-sync did the trick. I even helped out and sent a pull request to add some things to the README for that project as the instructions were a bit unclear.

So got the Recipe Box finished and my first Hacktoberfest PR. Booyah!

I’m taking the plunge and learning Angular 2 now. Overall, I’m really like how much less “loosey goosey” it is versus React. TypeScript is pretty neat too.

Anyway, couldn’t you use a service to inject the local storage data into the components and set it once it’s been modified? Keep in mind I’m completely new to it, so that might be super wrong!

Hey @zaclem01,

Agreed on the “I dislike how loosey goosey” React is. TypeScript is also vastly superior to JSX in my opinion.

That’s essentially what I did using this module. It’s in my service and any time my recipe list changed, I pushed that new array of recipes into local storage. The component just called the service and did a (pseudocode):

if localstorage is blank

fetch Recipe Array


fetch localstorage

Here is really cool tutorial how to use angular and localstorage: Angular + Local Storage