DirectiveCDK Overlay

Popconfirm

Small "Are you sure?" panel anchored to its trigger. Emits confirmed or cancelled.

Installation

import { WrPopconfirm } from 'ngwr/popconfirm';

@Component({ imports: [WrPopconfirm] })
export class MyComponent {}

Basic usage

Last result: —
<wr-btn
  color="danger"
  [wrPopconfirm]="'Delete this item?'"
  confirmText="Delete"
  confirmColor="danger"
  (confirmed)="remove()"
  (cancelled)="onCancel()"
>Delete</wr-btn>

Template reference

The directive exports itself as wrPopconfirm, so a template can raise the question from a control other than the one it is attached to.

<wr-btn wrPopconfirm="Delete this file?" #ask="wrPopconfirm" (confirmed)="remove()">
  Delete
</wr-btn>

<!-- Anywhere else in the same template -->
<wr-btn [disabled]="ask.isOpen()" (click)="ask.open()">Ask again</wr-btn>

API

NameDescriptionTypeDefault
wrPopconfirmrequiredConfirmation message.string
positionAnchor side.WrPopconfirmPosition'top'
confirmTextConfirm button text. Falls back to popconfirm.confirm.string | nullnull
cancelTextCancel button text. Falls back to popconfirm.cancel.string | nullnull
ariaLabelAccessible name of the confirmation dialog. role="dialog" with no name announces as a bare "dialog". Falls back to popconfirm.label.string | nullnull
confirmColorColor of the confirm button.WrColor'primary'
(confirmed)Fires when the user clicks confirm.void
(cancelled)Fires when the user clicks cancel or dismisses the overlay.void