Vito c5ac798c5b [ADF-4327] added templating for content dialog (#4549)
* [ADF-4327] added templating for content dialog

* [ADF-4327] added unit test and documentation
2019-04-04 12:44:47 +01:00

1.8 KiB

Title, Added, Status, Last reviewed
Title Added Status Last reviewed
Confirm dialog component v2.3.0 Active 2019-01-22

Confirm dialog component

Requests a yes/no choice from the user.

Confirm dialog

Basic Usage

constructor(private dialog: MatDialog) {}

...

let files = [
    // Files defined here...
];

const dialogRef = this.dialog.open(ConfirmDialogComponent, {
    data: {
        title: 'Upload',
        message: `Are you sure you want to upload ${files.length} file(s)?`
    },
    minWidth: '250px'
});

dialogRef.afterClosed().subscribe((result) => {
    if (result === true) {
        event.resumeUpload();
    }
});

Rendering custom html body

It is possible now to render a custom html instead of a plain message as confirm body via the attribute htmlContent. The html will be sanitized and then showed.

constructor(private dialog: MatDialog) {}

...

let files = [
    // Files defined here...
];

const dialogRef = this.dialog.open(ConfirmDialogComponent, {
    data: {
        title: 'Upload',
        htmlContent: '<div> <p>A</p> <p>Custom</p> <p>Content</p> </div>'
    },
    minWidth: '250px'
});

dialogRef.afterClosed().subscribe((result) => {
    if (result === true) {
        event.resumeUpload();
    }
});

Details

This component lets the user make a yes/no choice to confirm an action. Use the Angular MatDialog service to open the dialog, as shown in the example, and pass a data object with properties for the title and message to show. The afterClosed event of the MatDialog gives you the user's choice via the result parameter.