Angular 获取错误,因为找不到名称';ProductFormComponent';即使我在entryComponents数组中添加了组件

Angular 获取错误,因为找不到名称';ProductFormComponent';即使我在entryComponents数组中添加了组件,angular,typescript,Angular,Typescript,我想在单击按钮时获得弹出对话框。我已在entryComponents数组中添加了组件名称,但仍然出现以下错误: src/app/homepage/homepage.component.ts:29:19中出错-错误TS2304:找不到名称“ProductFormComponent”。 29 this.dialog.open(ProductFormComponent,dialogConfig) app.modules.ts: import {MatDialogModule} from '@angul

我想在单击按钮时获得弹出对话框。我已在entryComponents数组中添加了组件名称,但仍然出现以下错误:

src/app/homepage/homepage.component.ts:29:19中出错-错误TS2304:找不到名称“ProductFormComponent”。 29 this.dialog.open(ProductFormComponent,dialogConfig)

app.modules.ts:

import {MatDialogModule} from '@angular/material/dialog';

@NgModule({



  declarations: [
    AppComponent,
    LoginComponent,
    HomepageComponent,
    ProductFormComponent,
],

  imports: [
    BrowserModule,
    AppRoutingModule,
    MatCardModule,
    ReactiveFormsModule,
    MatInputModule,
   MatFormFieldModule,
    BrowserAnimationsModule,
    MatSelectModule,
    MatDatepickerModule,
    MatNativeDateModule,
    MatButtonModule,
    MatIconModule,
    MatDialogModule,
    ],

    
    entryComponents: [ProductFormComponent],
      

  providers: [ServiceService],
bootstrap: [AppComponent],

})
export class AppModule { }
Homepage.components.ts文件:

import { Component, OnInit } from '@angular/core';
import { MatDialog,MatDialogConfig,MatDialogRef} from '@angular/material/dialog';
@Component({
  selector: 'app-homepage',
  templateUrl: './homepage.component.html',
  styleUrls: ['./homepage.component.css']
})
export class HomepageComponent implements OnInit {

  constructor( private dialog: MatDialog ) { }

  ngOnInit(): void {
  }



oncreate(){
    
const dialogConfig = new MatDialogConfig();

        dialogConfig.disableClose = true;
        dialogConfig.autoFocus = true;

 this.dialog.open(ProductFormComponent,dialogConfig);
}

}
Homepage.component.html:

<div class="button-row" >
    <button mat-raised-button (click)="oncreate()">

        <mat-icon>add</mat-icon>Create
   </button>
    </div>

您需要在
主页.components.ts中导入
ProductFormComponent
您需要在
主页.components.ts中导入
ProductFormComponent

import { Component, OnInit } from '@angular/core';
import {ServiceService} from '../../shared/service.service';
@Component({
  selector: 'app-product-form',
  templateUrl: './product-form.component.html',
  styleUrls: ['./product-form.component.css']
})

export class ProductFormComponent implements OnInit {
  constructor(public service: ServiceService) { }
  ngOnInit(): void {
   }
}