ngx-environment-variable
Angular x script to set environment variables like Node Js environment variables
Angular
(Using "ngx-environment-variable"): ngxEnv.ENVIRONMENT_VARIABLENode
: process.env.ENVIRONMENT_VARIABLE
installation
npm install ngx-environment-variable OR yarn add ngx-environment-variable
How to use ?
- Put declaration in
src/typings.d.ts
declare ;
- Delete
environment
import statement and put following piece of code above theAppModule
import statement insrc/main.ts
:
;;setNgxEnvenvironment, ;
- Use
ngxEnv
to environemt variables defined inenvironment.ts
inside component, directive, pipe and module class.
setNgxEnv(environment, options)
options parameters:
Option | Detail |
---|---|
origin | value provided here is matched with current window origin. If it does not match ngxEnv.<ENV_VAR> will return undefined for all environment variables. |
envVarName | value provided here will rename ngxEnv . Environment variable can be used as <envVarName>.<ENV_VAR> .Warning : do not use any reserved keyword or any window object property. Do NOT forgot to change your declaration statement in src/typings.d.ts . |
Author
Saurav Singh
LICENSE
MIT