aboutsummaryrefslogtreecommitdiffstats
path: root/src/angular/modals/modal-button.component.ts
blob: 07f81dd88970d76ba0960dcfa200cd8be9dda5c5 (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, EventEmitter, Output } from "@angular/core";
import { ButtonComponent } from "../buttons/button.component";
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;
    @Output() closeModalEvent: EventEmitter<any> = new EventEmitter<any>();
    @HostListener('click') invokeCallback = (): void => {
        if (this.callback) {
            this.callback();
        }
        if (this.closeModal) {
            this.closeModalEvent.emit();
        }
    }

    constructor() {
        super();
        this.closeModal = false;
    }

}