Angular2 material dialog has issues - Did you add it to @NgModule.entryComponents?

前端 未结 11 2262
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 06:37

I am trying to follow the docs on https://material.angular.io/components/component/dialog but I cannot understand why it has the below issue?

I added the below on my

11条回答
  •  庸人自扰
    2020-12-04 06:58

    While integrating material dialog is possible, I found that the complexity for such a trivial feature is pretty high. The code gets more complex if you are trying to achieve a non-trivial features.

    For that reason, I ended up using PrimeNG Dialog, which I found pretty straightforward to use:

    m-dialog.component.html:

    
      Content
    
    

    m-dialog.component.ts:

    @Component({
      selector: 'm-dialog',
      templateUrl: 'm-dialog.component.html',
      styleUrls: ['./m-dialog.component.css']
    })
    export class MDialogComponent {
      // dialog logic here
    }
    

    m-dialog.module.ts:

    import { NgModule } from "@angular/core";
    import { CommonModule } from "@angular/common";
    import { DialogModule } from "primeng/primeng";
    import { FormsModule } from "@angular/forms";
    
    @NgModule({
      imports: [
        CommonModule,
        FormsModule,
        DialogModule
      ], 
      exports: [
        MDialogComponent,
      ], 
      declarations: [
        MDialogComponent
      ]
    })
    export class MDialogModule {}
    

    Simply add your dialog into your component's html:

     
    

    PrimeNG PrimeFaces documentation is easy to follow and very precise.

提交回复
热议问题