如何在Angular中进行确认对话模式

时间:2017-07-16 08:05:25

标签: angular

我想在表格中确认删除行但不在Angular中使用确认默认值。

1 个答案:

答案 0 :(得分:0)

我建议您使用primeng confirm Dialogue box

html(使用p-confirbox指令)

<p-confirmDialog header="Confirmation" icon="fa fa-question-circle" width="425"></p-confirmDialog>

<button type="text" (click)="confirm()" pButton icon="fa-check" label="Confirm"></button>

在您的组件中导入primeng并通过以下方式调用确认框

import {ConfirmDialogModule,ConfirmationService} from 'primeng/primeng';

export class ConfirmDialogDemo { 

    constructor(private confirmationService: ConfirmationService) {}

    confirm() {
        this.confirmationService.confirm({
            message: 'Are you sure that you want to perform this action?',
            accept: () => {
                //Actual logic to perform a confirmation
            }
        });
    }
}