Home > Software engineering >  Call component from another module not working
Call component from another module not working

Time:09-27

Module to be shared

exports: [ PatientClinicalTabComponent ],

which is having a emitter patient id

Module to be Imported imports: [ PatientModule ]

Html Page

<ng-template ngbNavContent>
      <app-patient-clinical-tab [patientId]='patientId'>
      </app-patient-clinical-tab>
    </ng-template>

But it showing error when the project is build

Error: projects/order/src/app/order-create-edit-tab/order-create-edit-tab.component.html:149:11 - error NG8001: 'app-patient-clinical-tab' is not a known element:

  1. If 'app-patient-clinical-tab' is an Angular component, then verify that it is part of this module.
  2. If 'app-patient-clinical-tab' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

149 <app-patient-clinical-tab [patientId]='patientId'> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

projects/order/src/app/order-create-edit-tab/order-create-edit-tab.component.ts:15:16 15 templateUrl: './order-create-edit-tab.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component OrderCreateEditTabComponent.

Error: projects/order/src/app/order-create-edit-tab/order-create-edit-tab.component.html:149:37 - error NG8002: Can't bind to 'patientId' since it isn't a known property of 'app-patient-clinical-tab'.

  1. If 'app-patient-clinical-tab' is an Angular component and it has 'patientId' input, then verify that it is part of this module.
  2. If 'app-patient-clinical-tab' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
  3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.m

149 <app-patient-clinical-tab [patientId]='patientId'> ~~~~~~~~~~~~~~~~~~~~~~~

projects/order/src/app/order-create-edit-tab/order-create-edit-tab.component.ts:15:16 15 templateUrl: './order-create-edit-tab.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component OrderCreateEditTabComponent

CodePudding user response:

you have to options:

  • declare PatientClinicalTabComponent in PatientModule(and nowhere else). Just use it inside PatientModule
  • create e new module called PatientClinicalTabModule. Declare PatientClinicalTabComponent inside PatientClinicalTabModule and then import PatientClinicalTabModule inside PatientModule

this will solve your problem

  • Related