# ng-environment

> External environment for angular

Latest version **0.0.4** (published 2020-03-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng-environment
pnpm add ng-environment
yarn add ng-environment
bun add ng-environment
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2020-03-10 |
| First published | 2020-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 148.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Prasad Bhamre |
| Maintainers | peb1791 |
| Keywords | angular, environment, external environment, variables, environment variables |

## Links

- npm: https://www.npmjs.com/package/ng-environment
- Repository: https://github.com/prasad1791/ng-environment
- Issues: https://github.com/prasad1791/ng-environment/issues
- npm.io page: https://npm.io/package/ng-environment

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 0.0.4 (latest) — 2020-03-10
- 0.0.1 — 2020-03-07

## README

# ng-environment

Library allows you to provide environment variables externally for angular project. You are also allowed to change them after build.

# Features
  - Accept the [JSON](https://www.json.org/json-en.html) and [XML](https://en.wikipedia.org/wiki/XML) file.
  - Allow to Change the environment variables without new angular build.

## Download and Installation
### Step 1: Install `ng-environment`:

#### NPM
```shell
npm install ng-environment --save
```
#### YARN
```shell
yarn add ng-environment
```
### Step 2: Include a `JSON` or `XML` file: 
To allow external environment variables include `.json` or `.xml` file in `assets` folder. Angular cli will copy these files to `dist` folder after build.

### Step 3: Import the `EnvironmentModule`:
```js
import {EnvironmentModule} from 'ng-environment';

@NgModule({
  declarations: [AppComponent],
  imports: [EnvironmentModule.forRoot('assets/config.json')],
  bootstrap: [AppComponent]
})
export class AppModule {}
```

### Step 4 : Access environment variables inside the components

#### Import `EnvironmentService` in the component

```js
import {EnvironmentService} from 'ng-environment';
import {HttpClient} from '@angular/common/http';
  export class AppComponent {
  
  constructor(private http: HttpClient,private envService:EnvironmentService){
    this.dataRes();
  }

  public dataRes():void{
    this.http.get(`${this.envService.envConfig.apiUrl}employees`)
    .subscribe((res)=>{
      const resData =res;
    },(error)=>console.log(error));
  }
}
```

---
_Source: https://npm.io/package/ng-environment · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
