1 import { Component, HostListener, OnInit, ViewChild } from '@angular/core'
3 import { ModalDirective } from 'ngx-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',
15 styles: [ '.button { padding: 0 13px; }' ]
17 export class ConfirmComponent implements OnInit {
18 @ViewChild('confirmModal') confirmModal: ModalDirective
23 constructor (private confirmService: ConfirmService) {
28 this.confirmModal.config = {
33 this.confirmService.showConfirm.subscribe(
34 ({ title, message }) => {
36 this.message = message
43 @HostListener('keydown.enter')
45 this.confirmService.confirmResponse.next(true)
49 @HostListener('keydown.esc')
51 this.confirmService.confirmResponse.next(false)
56 this.confirmModal.show()
60 this.confirmModal.hide()