Angular2 module has no exported member

前端 未结 10 1256
梦谈多话
梦谈多话 2020-12-29 01:09

For a website with authentication in Angular2, I want to use a component of the authentication submodule in the main app component. However, I keep getting the following err

10条回答
  •  执笔经年
    2020-12-29 01:44

    In my module i am exporting classes this way:

    export { SigninComponent } from './SigninComponent';
    export { RegisterComponent } from './RegisterComponent';
    

    This allow me to import multiple classes in file from same module:

    import { SigninComponent, RegisterComponent} from "../auth.module";
    

    PS: Of course @Fjut answer is correct, but same time it doesn't support multiple imports from same file. I would suggest to use both answers for your needs. But importing from module makes folder structure refactorings more easier.

提交回复
热议问题