Search code examples
angular-materialtooltipangular8

Using MatTooltip in MatIcon in Angular 8 causing problem


I try to show tooltip message in an input where a suffix icon appears. I think I did everywhing as the documentation says, but always got an error instead of what I want.

ERROR Error: No component factory found for TooltipComponent. Did you add it to @NgModule.entryComponents?

Component.ts

@NgModule({
  declarations: [
    MyComponent
  ],
  imports: [
    MatTooltipModule
]

Component.html

<mat-form-field>
 <input matInput placeholder="placeHolder" formControlName="myFormControl">
 <mat-icon matSuffix
   matTooltip="My tooltip comes here"
   matTooltipPosition="left">
    help_outline
 </mat-icon>
</mat-form-field>

Solution

  • ERROR Error: No component factory found for TooltipComponent. Did you add it to @NgModule.entryComponents? From this error i can tell you that you need to add TooltipComponent to entryComponetns in your module;

    @NgModule({
      declarations: [
        MyComponent
      ],
      imports: [
        MatTooltipModule
    ],
    entryComponetns: [TooltipComponent]