Add custom Component to ionic modal

Hi ppl,
Im trying to do something simple. add my custom component to a modal.
but when I add the component in the modal HTML I receive this error:

core.js:1449 ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can’t bind to ‘book’ since it isn’t a known property of ‘custom-module’.

  1. If ‘custom-module’ is an Angular component and it has ‘book’ input, then verify that it is part of this module.
  2. If ‘custom-module’ is a Web Component then add ‘CUSTOM_ELEMENTS_SCHEMA’ to the ‘@NgModule.schemas’ of this component to suppress this message.

Can someone help me ?
Or give-me an exemple ?
sorry for this noob question but Im new in ionic/angular

Tks,
Pedro

First, if the modal page is lazy loaded…

In your modal file (example: driver-modal.module.ts):

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ContactComponentModule } from './../../components/contact/contact.module';

import { DriverModal } from './driver-modal';

@NgModule({
  declarations: [
    DriverModal,
  ],
  imports: [
    IonicPageModule.forChild(DriverModal),
    ContactComponentModule,
  ]
})
export class DriverModalModule {}

And your component “contact.module.ts”:

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ContactComponent } from './contact';

@NgModule({
  declarations: [
    ContactComponent,
  ],
  imports: [
    IonicPageModule.forChild(ContactComponent),
  ],
  exports: [
    ContactComponent
  ]
})
export class ContactComponentModule {}

After adding the file, you may need to restart “ionic serve” in sometime.

1 Like

Thank you @sonicwong you was very helpful to me :). with your code realized what has my mistake. So all my app is lazy loading but my component not, so I made a big mess there.