@3go/environment

## Install

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
11Sep 11, 2018Jul 17, 2018Minified + gzip package size for @3go/environment in KB

Readme

@3go/environment

Install

$ yarn add @3go/environment

or

$ npm i @3go/environment --save

How to

Works with angular 5 and 6.

Demos

Angular 5:

https://stackblitz.com/edit/3go-environment-angular5

Angular 6:

  • Dependencies to work: rxjs-compat .

https://stackblitz.com/edit/3go-environment-angular6

import:

app.module.ts

@NgModule({
  imports: [
    (...)
    GoEnvironmentModule.forRoot({
      name: "params",
      environments: {
        "localhost": "localhost",
        "prod": "api.myapp.com"
        }
      })
  ],

#ConfigFile: Default values

name: "config", extension: "json", path: "./assets/", environments: { "localhost": "localhost" }

app.component.ts

export class AppComponent implements OnInit {
  constructor(private envService: GoEnvironmentService) {}

  ngOnInit(): void {
    this.envService.config().then(
      () => this.envService.replace(environment)
    );
  }
}

create a json file with a same name of your config.

params.json

{
  "localhost": {
    "url": "some value here",
    "api": "some value here"
  },
  "prod": {
    "url": "some value here",
    "api": "some value here"
  }
}

Use native environment

{{ environment.url }}
{{ environment.api }}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.