summaryrefslogtreecommitdiffstats
path: root/src/angular/modals/modal-button.component.ts
blob: 4fa5b7c29ab0124f9b389d2f6daba3769cb635a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Component, Input, HostListener } from "@angular/core";
import { ButtonComponent } from "../buttons/button.component";
import { ModalService } from "./modal.service";
import template from "./../buttons/button.component.html";

@Component({
    selector: "sdc-modal-button",
    template: template
})
export class ModalButtonComponent extends ButtonComponent {

    @Input() public id?: string;
    @Input() public callback: Function;
    @Input() public closeModal: boolean;
    @HostListener('click') invokeCallback = (): void => {
        if (this.callback) {
            this.callback();
        }
        if (this.closeModal) {
            this.modalService.closeModal();
        }
    }

    constructor(private modalService: ModalService) {
        super();
        this.closeModal = false;
    }

}