Defining localstorage for angular2 app

独自空忆成欢 提交于 2019-12-08 19:49:30

localStorage should be defined at global JS level, but you don't have the Typescript definition for it so the compiler says that is not defined.

Just try to put at the start of the file

declare var localStorage : any;

and then use localStorage in the TypeScript code.

You can also try to use angular2-localstorage module.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!