Angular 2 - Whats the best way to store global variables like authentication token so all classes have access to them?

后端 未结 4 709
后悔当初
后悔当初 2020-12-13 14:49

Angular 2 question only:

Whats the best way to store global variables like authentication token or base url (environment settings) so that all classes can have acces

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 15:36

    In your specific scenario you would actually want to store token in localstorage since a page refresh will cause you to loose token value stored in memory.

提交回复
热议问题