how can we use environment variable in angular version >=2

后端 未结 3 820
离开以前
离开以前 2021-01-02 06:44

I am now reading the angular4 doc, and noticed, there is one folder, environments, and under which, there are multiple environment files, such as environment.ts, environment

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-02 07:19

    Assuming the environment.ts file exports, for example, a constant named environment, then first you import the constant (using the appropriate path):

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

    Then in code you just use the constant:

    let mything = environment.mything;
    

提交回复
热议问题