1 import { Component, HostListener, OnInit, ViewChild } from '@angular/core';
3 import { ModalDirective } from 'ng2-bootstrap/modal';
5 import { ConfirmService } from './confirm.service';
7 export interface ConfigChangedEvent {
8 columns: { [id: string]: { isDisplayed: boolean }; };
9 config: { resultsPerPage: number };
13 selector: 'my-confirm',
14 templateUrl: './confirm.component.html'
16 export class ConfirmComponent implements OnInit {
17 @ViewChild('confirmModal') confirmModal: ModalDirective;
22 constructor (private confirmService: ConfirmService) {
27 this.confirmModal.config = {
32 this.confirmService.showConfirm.subscribe(
33 ({ title, message }) => {
35 this.message = message;
42 @HostListener('keydown.enter')
44 this.confirmService.confirmResponse.next(true);
48 @HostListener('keydown.esc')
50 this.confirmService.confirmResponse.next(false);
55 this.confirmModal.show();
59 this.confirmModal.hide();