angular + material 弹出对话框做成

夹谷茂
2023-12-01

1.按照官网的这个做就行

https://material.angular.io/components/dialog/overview

2.在app.module.ts中定义entryComponents(动态加载)

@NgModule({

declarations: [

AppComponent,

DialogtestComponent

],

entryComponents: [需要动态加载的classname],

3.有几个注意点需要注意

当出现以下错误时

Can't bind to 'ngModel' since it isn't a known property of 'input'.

解决方案

import { FormsModule, ReactiveFormsModule } from '@angular/forms';

@NgModule({

declarations: [

AppComponent,

DialogtestComponent

],

entryComponents: [DialogtestComponent],

imports: [

FormsModule,

 类似资料: