Documentation
Fuse Components
Services

## Confirmation

FuseConfirmationService is a singleton service for creating confirmation and information dialogs. Internally it uses MatDialog to create and show the dialog.

## Module

import { FuseConfirmationModule } from '@fuse/services/confirmation';

## Confirmation Config

Here is the interface for the Confirmation configuration:

export interface FuseConfirmationConfig { title?: string; message?: string; icon?: { show?: boolean; name?: string; color?: | 'primary' | 'accent' | 'warn' | 'basic' | 'info' | 'success' | 'warning' | 'error'; }; actions?: { confirm?: { show?: boolean; label?: string; color?: | 'primary' | 'accent' | 'warn'; }; cancel?: { show?: boolean; label?: string; }; }; dismissible?: boolean; }

Name | Description
--- | ---
title | Title of the confirmation dialog, HTML is allowed.
message | Message of the confirmation dialog, HTML is allowed.
icon.show | Whether to show the icon.
icon.name | Name of the icon.
icon.color | Color of the icon.
actions.confirm.show | Whether to show the confirmation button.
actions.confirm.label | Label of the confirmation button.
actions.confirm.color | Color of the confirmation button.
actions.cancel.show | Whether to show the cancel button.
actions.confirm.label | Label of the cancel button.
dismissible | Sets the dismissible status of the confirmation dialog. If `false`, confirmation dialog cannot be closed by clicking on backdrop or pressing Escape key. The close button on the top right corner also won't show up.

## Methods

open(config: FuseConfirmationConfig): MatDialogRef<FuseConfirmationDialogComponent>
Opens the confirmation dialog with the given configuration

## MatDialogRef

Since `FuseConfirmationService` uses MatDialog behind the scenes, it returns a reference to the created dialog. You can use all available methods from that reference such as `updateSize` and `updatePosition` to further customize the dialog.

See https://material.angular.io/components/dialog/api#MatDialogRef for the complete list of available methods.

Using the reference, you can also access to the user input:

// Open the confirmation and save the reference const dialogRef = this._fuseConfirmationService.open({...}); // Subscribe to afterClosed from the dialog reference dialogRef.afterClosed().subscribe((result) => { console.log(result); });

Result | Description
--- | ---
`'confirmed'` | This is the result if the user pressed the Confirm button.
`'cancelled'` | This is the result if the user pressed the Cancel button.
`undefined` | This is the result if the confirmation dismissed either using the close button, clicking on the backdrop or pressing the Escape key.