Skip to content

Schematic for Angular Material Dialog #17994

@marc-wilson

Description

@marc-wilson

Feature Description

Provide a brief summary of the feature you would like to see.
I find the setup process of components to be quite redundant in some cases. An example is creating a dialog. I see that angular material has schematics. It would be nice if there was something for a dialog:
ng generate @angular/material:dialog <component-name>

This would generate a component like so:

import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';

@Component({
  selector: 'app-aggregate-dialog',
  templateUrl: './aggregate-dialog.component.html',
  styleUrls: ['./aggregate-dialog.component.scss']
})
export class AggregateDialogComponent implements OnInit {
  private _dialogRef: MatDialogRef<AggregateDialogComponent>;
  constructor(dialogRef: MatDialogRef<AggregateDialogComponent>, @Inject(MAT_DIALOG_DATA) data: any) {
    this._dialogRef = dialogRef;
  }

  ngOnInit() {
  }

}

This would also mean the dialog component would be added to the entryComponents in the module.

Use Case

Describe the use case(s) that the proposed feature would enable.
For dialog-heavy applications, setting up dialogs require quite a few steps. It would be nice if this was a little more streamlined. Given that (I believe) if you want to use an Angular Material dialog, it requires it's own component I think it would be useful for the proper (or common) references to be added when generated. It sounds like the entryComponents step won't be needed in v9, so that is nice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: ng-generateSchematics that generate code in user projectsfeatureThis issue represents a new feature or feature request rather than a bug or bug fixneeds: discussionFurther discussion with the team is needed before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions