angular-cli: Conditional Imports using an environment variable

后端 未结 2 599
情书的邮戳
情书的邮戳 2020-12-06 17:23

Is there a way to conditionally change imports based on an environment variable in angular-cli@1.0.0-beta.16? I\'m trying to do it in a way that doesn\'t require code change

2条回答
  •  不知归路
    2020-12-06 18:13

    Change your MyService import to:

    import { MyService } from './myservice/index';

    The surrounding {} will tell the compiler to import a single export from the file. If you want to be able to import like:

    import MyService from './myservice/index';

    Then you must have a default export in index.ts e.g:

    export default MyService; .

    More information on TypeScript modules can be found here: https://www.typescriptlang.org/docs/handbook/modules.html

提交回复
热议问题