Daniel Stradowski Daniel Stradowski - 3 months ago 119
TypeScript Question

Access HTML5 local storage from Angular2

I'm following this tutorial: https://medium.com/@blacksonic86/authentication-in-angular-2-958052c64492 about authentication in Angular2.

I've the issue with this part:

import localStorage from 'localStorage';


I've read somewhere else that I should use this library https://github.com/marcj/angular2-localstorage to access local storage in HTML5. Is it really the only option? Can I access HTML5 local storage from angular2 without using extra modules?

Answer

You can use localStorage directly in your service without import localStorage from 'localStorage';.

Comments