I'm using VS Code and I'm getting warnings in my code. I suppose I'm doing something wrong however the application is working as expected
<div class="search-wrapper">
<input
(keyup)="onKeyup($event)"
type="search"
id="searchInput"
placeholder="Search..."
/>
<button class="icon" (click)="clear()"><i class="fa fa-times"></i></button>
</div>
import { Component, OnInit } from "@angular/core";
import { SearchService } from "../services/search.service";
@Component({
selector: "app-search",
templateUrl: "./search.component.html",
styleUrls: ["./search.component.scss"]
})
export class SearchComponent implements OnInit {
constructor(private fs: SearchService) {}
ngOnInit() {}
onKeyup(event) {
this.fs.updateFilter(searchInput.value);
}
clear() {
this.fs.updateFilter("");
searchInput.value = "";
}
}
Problem is with reading value from input tag. As you can see in the code I'm just using the id to get access to the data but VS Code is showing me a warning that Cannot find searchInput. The code is working fine but since I'm getting the warning I assume I'm doing something wrong.