简体   繁体   English

如何将变量传递给角度库

[英]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.所以我有一个 Angular 库,在我的主项目上安装了一个服务,我想知道是否可以检索全局 url 变量或我在主项目中定义的 config.json 文件的字段。 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在 src/environments/ 文件夹中,您可以拥有一个包含设置变量的 environment.ts 文件,并将其用于

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 https://angular.io/guide/build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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