简体   繁体   中英

How do I pass a variable to angular library

So I have an Angular library with a service installed on my main project and I want to know if it's possible to retrieve a global url variable or a field of my config.json file I defined in my main project. Would be nice to know how too.

In the src/environments/ folder you can have an environment.ts file with settings variables and use it with

import { environment } from './../environments/environment';

Then any variable you have in the file will be available.

You can even have different files for each of your environments.

https://angular.io/guide/build

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM