I need to get the search list using speciesName from the table and I tried to get the data while pressing enter key, but, it is giving me that input data is not work (undefined).
How can I pass the search value to the type script method in the same input?
The type script component is like this:
getSearchResult(speciesName) {
this.speciesName = speciesName;
this.speciesService.getSearchResult(speciesName).subscribe(result => {
this.speciesList = result.results;
}, error => this.toastr.error(error.statusText, '', {
timeOut: 3000
}));
}
and the html for the component is like this:
<form class="form-inline" id="searchForm">
<div class="form-group">
<input class="form-control mr-sm-2" type="search" placeholder="Enter Species Name ..."
id="speciesNameSearch" name="speciesNameSearch" aria-label="Search"
(keyup.enter)="getSearchResult(speciesNameSearch)">
</div>
</form>
After I put the search criteria and input the Enter key it giving me not found because the value of speciesName is undefined.
How can I get speciesName value after I input it and click enter key and insert it to the search method?