import { Component } from
'@angular/core'
;
import {
AbstractControl, FormBuilder,
FormGroup
} from
'@angular/forms'
;
@Component({
selector:
'app-root'
,
templateUrl:
'./app.component.html'
,
styleUrls: [
'./app.component.css'
]
})
export class AppComponent {
searchValue: any;
condition: boolean =
false
;
prevText: string =
''
;
list_lang: any[] = [
'java'
,
'c++'
,
'python'
,
'c'
,
'javascript'
];
res_list = [];
res_cnt: number = 0;
onSubmit($event: KeyboardEvent) {
if
($event.keyCode === 13) {
this
.condition =
true
;
this
.prevText =
this
.searchValue;
this
.res_cnt = 0;
this
.res_list = [];
setTimeout(() => {
this
.condition =
false
;
for
(let i = 0; i <
this
.list_lang.length; i++) {
if
(
this
.list_lang[i] ===
this
.prevText.toLowerCase()
||
this
.list_lang[i].startsWith(
this
.prevText)) {
this
.res_cnt += 1;
this
.res_list.push(
this
.list_lang[i]);
}
}
}, 3000);
this
.searchValue =
null
;
}
}
}