简体   繁体   中英

can't use custom component in app.component.ts in ionic 3

  1. I've created a ionic 3 project with a sidebar.
  2. I've defined couple of components in components/component.module.ts for lazy loading
  3. I have a profile-pic component and I need to use it in sidebar which app.component.html
  4. so to use this, I included component.module.ts in app.component.ts but got the error.

I've googled myself and found out that we can't include component.module.ts which is lazy loading in app.component.ts .

Not sure this is the correct answer but I need to use a component in app.component.html .

Any suggestions?

FYI, I wanna use custom components in Sidebar(which is app.component.html ), not in Pages.

In pages, it works well if I import component.module .

Thanks.

import component in app.modules.ts file

import { ComponentsModule } from '../../components/components.module'

imports: [
    ComponentsModule,

  ],

This is what works for me. Use the Component as a service. Declare it in the providers section of the main module, then import it in app.component.ts and inject it in the constructor of it.

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