Skip to content

(Dialog) Component-less alert and confirm dialogs #17048

@iget-master

Description

@iget-master

Feature Description

My proposal is to create one or two methods on the MatDialog provider/controller to allow component-less alert and confirm dialogs, for example:

// Alert dialog
this.dialog.alert({
    title: 'Forbidden',
    message: 'The resource you are trying to access is forbidden.',
    okButton: 'OK'
})

// Confirm dialog
this.dialog.confirm({
    title: 'Server error',
    message: 'The server is currently in maintenance.',
    confirmButton: 'Retry',
    cancelButton: 'Cancel'
})

Alternatively, both alert and confirm could be on a single method:

this.dialog.alert({
    title: 'The title',
    message: 'The message',
    confirmButton: 'OK', // Optional, only for confirm
    dismissButton: 'Dismiss'
}).afterClose().subscribe((result: boolean) => console.log); // True if confirm, false if dismiss.

Use Case

Currently, we have to create a component for every dialog, event the simplest dialog. This is painful and useless in most cases. Other alternatives (what I do) is to create a AlertService that does it for me. But makes no sense maintain it if it could be a simple feature of MatDialog

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussionarea: material/dialogfeatureThis 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