New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ng-environment

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-environment

External environment for angular

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

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 and XML file.
  • Allow to Change the environment variables without new angular build.

Download and Installation

Step 1: Install ng-environment:

NPM

npm install ng-environment --save

YARN

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:

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

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));
  }
}

Keywords

angular

FAQs

Package last updated on 10 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts