I am working on autocomplete application
<form novalidate [formGroup] ="formG">
<input type="text" placeholder="enter"
formGroupName="formCont" class="searchBox"
(click)="showDrop()" id="search">
<input type="text">
</form>
<div class="seracDropDown" *ngIf = "showDropDown"></div>
and the code part is:
import { Component, HostListener } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
@Component({
selector : "app-root",
templateUrl : './app.component.html',
styleUrls : ['./app.component.css']
})
export class AppComponent {
showDropDown : boolean = false;
formG = new FormGroup({
formCont : new FormControl()
})
showDrop (){
this.showDropDown = !this.showDropDown;
}
@HostListener('click',['$ev.target'])
onClickCalled(target) {
if(target.id =="search") {
console.log("S");
}
}
But it throws error:
Cannot read property 'target' of undefined
Could anyone help me?