Member Junction
    Preparing search index...

    MJConfirmService — Imperative, Promise-based confirmation prompts.

    The one-liner replacement for native window.confirm() (an anti-pattern this codebase bans) and for the boilerplate of wiring <mj-confirm-dialog> into a template just to ask a yes/no question. It dynamically mounts an MJConfirmDialogComponent to document.body, shows it, and resolves a Promise<boolean>true on confirm, false on cancel/backdrop/Esc — then tears the component down.

    private confirm = inject(MJConfirmService);

    // Simplest — replaces `if (window.confirm('Discard changes?')) { ... }`
    if (await this.confirm.Confirm('Discard unsaved changes?')) {
    this.discard();
    }

    // Destructive delete with a detail line
    if (await this.confirm.ConfirmDelete({
    message: 'Delete this user?',
    detail: 'This action cannot be undone.',
    })) {
    await this.deleteUser();
    }

    Async work after confirm: because this resolves a boolean, the dialog has already closed by the time your await continues — there's no in-dialog spinner. When you need a "keep open + spinner while I save" UX, use the <mj-confirm-dialog> component directly with its Processing input instead.

    Synchronous guards: window.confirm blocks the thread; a synchronous CanClose/beforeunload guard that must return a boolean immediately cannot use this async service. Those rare cases stay on window.confirm as a documented exception.

    Index

    Constructors

    Methods

    Constructors

    Methods