passing environment variables to angular2 library

前端 未结 5 1841
Happy的楠姐
Happy的楠姐 2020-12-08 03:04

I\'ve created company internal library using angualr2-library yeoman generator.

Some of the angular services are using environment variables in our current applicati

5条回答
  •  北海茫月
    2020-12-08 03:13

    If You are still looking for the answer. In the current version i.e. Angular > 6, you don't have to do anything.

    The angular-cli commands "ng build --prod (for Production)& ng build (for Development)" will take care of it for you.

    Example: If you are running the project in development environment, all the variables are captured from src/environments/environment.ts. In your component library project just import "import { environment } from 'environments/environment';" (please make sure about the path) will takecare of the environment depending upon the angular-cli build command.

提交回复
热议问题