I wanted to create a global variable which is of type boolean, I wanted to utilize the same variable in multiple components (Without using Service).To be precise I also wanted to capture the variable value from any component if it is changed in other components.
CodePudding user response:
try declaring the variable in environment.ts file
CodePudding user response:
There are few options to do it.
- Environment variables : Declare the variable in
environment.ts
. Do note that you need to replicate it acrossenvionment.prod.ts
and other environment files if you may have. - Injection Token : Create a custom injection token, and pass it as a provider in your Component or Module. Details