The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

452573 (1) [Avatar] Offline
#1
Hello,

in the code example in Chapter 6.6 Helper service (also on GIT https://github.com/angular-in-action/portfolio/blob/master/src/app/services/local-storage.service.ts) I do not understand where "localStorage" is coming from.

I do see neither import of localStorage nor any other initialization like through DI.

Could you please shortly describe?

Kind regards,
Stephan
jeremy.wilken (208) [Avatar] Offline
#2
Great question, and something I didn’t clarity as well as I could have. The localStorage API is a browser feature, not Angular. There is no need to inject it, you just use it (just like window or document).

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage