import {Component, ViewEncapsulation, ComponentRef, ElementRef, Input, EventEmitter, Output} from '@angular/core';
@Component({
selector: 'modal-select',
template: `
`,
encapsulation: ViewEncapsulation.None,
})
/**
* API to an open alert window.
*/
export class ModalSelect {
@Input() public message: string = "Loading";
@Input() public options: string[] = [];
public selected: string;
/**
* if the value is true alert will be visible or else it will be hidden.
*/
public isOpen: boolean = false;
/**
* Emitted when a ok button was clicked
* or when Ok method is called.
*/
@Output() public alertOutput: EventEmitter
= new EventEmitter();
constructor(public _elementRef: ElementRef) {
}
/**
* Opens a alert window creating backdrop.
*/
open() {
this.isOpen = true;
}
close() {
this.isOpen = false;
if (!this.selected) {
this.selected = this.options[0];
}
this.alertOutput.emit(this.selected);
}
}