import { Component, OnInit, Input, Output, EventEmitter, HostListener } from '@angular/core';
@Component({
selector: 'select-comp',
templateUrl: './select.component.html',
styleUrls: ['./select.component.css']
})
export class SelectComponent implements OnInit {
@Input() i: IDialog;
@Input() value: string;
selectInput: string = ''
@Input() selectOptions: IOption[];
@Output('option') option: EventEmitter<string> = new EventEmitter<string>()
showAutocomplete: boolean = false;
@HostListener("document:keydown.escape", ["$event"]) onKeydownHandler(
evt: KeyboardEvent
) {
this.showAutocomplete = false;
}
// @HostListener("click", ["$event"])
// onLocalClick(event: Event) {
// this.showAutocomplete = false;
// }
constructor() { }
ngOnInit() {
// console.log('==', this.selectOptions);
}
search() {
this.showAutocomplete = true;
}
onSelectOption(option) {
console.log('---', option);
this.selectInput = option;
this.option.emit(this.selectInput);
this.showAutocomplete = false;
}
searchOption() {
this.showAutocomplete = true;
}
// hideSelect() {
// this.showAutocomplete = false;
// }
}
interface IDialog {
iconSrc: string;
iconAlt: string;
title: string;
closeBtnSrc: string;
closeBtnAlt: string;
textInfo: IText[];
labelForPrimaryThemeSelector: string;
primaryThemeOptions: IOption[];
labelForSecondaryThemeSelector: string;
secondaryThemeOptions: IOption[];
labelforSubThemeSelector: string;
subThemeOptions: IOption[];
messageInfo: IMessageInfo[];
labelForChooseExamOptions: string;
chooseExamDateOptions: IOption[];
labelForQuizOptions: string;
chooseQuizOptions: IOption[];
footerTitle: string;
radioBtnText: IRadio[];
labelForPhone: string;
labelForMail: string;
phonePrefixOptions: IOption[];
updateSettingsBtnText: string;
labelForTextarea: string;
labelForUploadBtn: string;
uploadBtnText: string;
uploadIconSrc: string;
uploadIconAlt: string;
uploadInfo: string;
btnUploadReportText: string;
btnRemoveReportText: string;
btnClearText: string;
btnCancelText: string;
btnSendText: string;
}
interface IText {
id?: string
text: string
}
interface IOption {
option: string;
}
interface IMessageInfo {
messageInfoIconSrc: string;
messageInfoIconAlt: string;
messageText: string;
linkText?: string;
linkHref?: string;
}
interface IRadio {
name: string;
value: string;
}