0.1.2 • Published 5 years ago

ng-environmenter v0.1.2

Weekly downloads
81
License
-
Repository
github
Last release
5 years ago

ng-environmenter

Angular environment sharing done easy

npm.io npm.io

Getting started

Install the package: npm install ng-environmenter

Environment configuration

Create a environments folder at root level of your workspace, and a environment file for each environment, like the following:

// environments/environment.ts
export const globalEnvironment = {
  production: false,
};

And extend it on yours application environment file:

// projects/app/src/environments/environment.ts
import { Environment } from 'ng-environemnter';
import { globalEnvironment } from '../../../../environments/environment.ts';

export const environment: Environment = {
  application: {},
  global: globalEnvironment
};

Implementing the Environmenter

Add it to your AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { environment } from '../environments/environment';
import { EnvironmenterModule } from 'ng-environmenter';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    EnvironmenterModule.forRoot(environment)
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

And inject the Environmenter on any file:

import { Component } from '@angular/core';
import { Environmenter } from 'ng-environmenter';

@Component({
  selector: 'app-component',
  template: `
    <p>{{ getEnvironment() | json }}</p>
  `,
})
export class AppComponent {
  constructor(
    private environmenter: Environmenter
  ) {}

  getEnvironment() {
    return [
      this.environmenter.getApplicationEnvironment(),
      this.environmenter.getGlobalEnvironment(),
      this.environmenter.getEnvironment(),
    ];
  }
}
0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago