0
  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.

Patrick Blind
  • 399
  • 1
  • 4
  • 15

2 Answers2

0

import component in app.modules.ts file

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

imports: [
    ComponentsModule,

  ],
rakshans1
  • 3
  • 2
  • I've followed your steps exactly but it's not working. `Uncaught Error: Template parse errors: Can't bind to 'user' since it isn't a known property of 'profile-pic'.` Looks like we can't import lazy-loading components module in app.module.ts – Patrick Blind Dec 20 '17 at 07:17
  • the profile pic component cannot get access to the user variable. you will need to pass it as properties while calling the component in app.component – rakshans1 Dec 20 '17 at 09:30
0

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.

Carol
  • 1