在 Angular 8 中使用 MatIcon 中的 MatTooltip 导致问题

Using MatTooltip in MatIcon in Angular 8 causing problem

我尝试在出现后缀图标的输入中显示工具提示消息。我想我按照文档所说的做了所有事情,但总是得到一个错误而不是我想要的。

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>

ERROR Error: No component factory found for TooltipComponent. Did you add it to @NgModule.entryComponents? 从这个错误我可以告诉你,你需要将 TooltipComponent 添加到模块中的 entryComponetns;

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