How can I set focus on an input by (click) event? I have this function in place but I\'m clearly missing something (angular newbie here)
sTbState: string = \
Get input element as native elements in ts file.
//HTML CODE
//TS CODE
@ViewChild("focusTrg") trgFocusEl: ElementRef;
onSetFocus() {
setTimeout(()=>{
this.trgFocusEl.nativeElement.focus();
},100);
}
we need to put this.trgFocusEl.nativeElement.focus();
in setTimeout()
then it'll work fine otherwise it will throw undefined error.