@dkx/mat-confirmation-dialog
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

DKX/Angular/MatConfirmationDialog

Confirmation dialog for angular material

Installation

$ npm install --save @dkx/mat-confirmation-dialog

or with yarn

$ yarn add @dkx/mat-confirmation-dialog

Usage

Module:

import {NgModule} from '@angular/core';
import {MatConfirmationDialogModule} from '@dkx/mat-confirmation-dialog';

@NgModule({
    imports: [
        MatConfirmationDialogModule,
    ],
})
export class AppModule {}

Component:

import {Component} from '@angular/core';
import {MatConfirmationDialogService} from '@dkx/mat-confirmation-dialog';

@Component({...})
export class MyComponent
{
    
    constructor(
        private confirmDialog: MatConfirmationDialogService,
    ) {}
    
    public openConfirmDialog(): void
    {
        const cd = this.confirmDialog.open('Are you sure?');
        
        cd.afterClosed().subscribe((result: boolean) => {
            if (result) {
                alert('Clicked on "yes"');
            } else {
                alert('Clicked on "no"');
            }
        });
    }
    
}

Configuration

Module:

import {NgModule} from '@angular/core';
import {MatConfirmationDialogModule, MatConfirmationDialogConfig, MAT_CONFIRMATION_DIALOG_CONFIG} from '@dkx/mat-confirmation-dialog';

const confirmDialogConfig: MatConfirmationDialogConfig = {
    trueButtonTitle: 'Maybe yes',
    falseButtonTitle: 'Maybe no',
};

@NgModule({
    imports: [
        MatConfirmationDialogModule,
    ],
    providers: [
        {
            provide: MAT_CONFIRMATION_DIALOG_CONFIG,
            useValue: confirmDialogConfig,
        },
    ],
})
export class AppModule {}

Readme

Keywords

none

Package Sidebar

Install

npm i @dkx/mat-confirmation-dialog

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

99.2 kB

Total Files

30

Last publish

Collaborators

  • davidkcz