When a user types 3 letters in the search box of my Kendo dropdown, I want to load data into the dropdown using an API call.
I've attempted it this way, but it's not working correctly. Can someone provide me with the correct solution?
.ts
public nameList: any[] = [];
modelChange(searchTerm: any){
if(searchTerm !== ""){
this.getNameList(searchTerm);
}
}
getNameList(searchTerm: any){
this.compsService.getNames(searchTerm).subscribe((res) => {
res.data.forEach((element: any) => {
this.nameList = element.name;
});
});
}
.html
<kendo-dropdownlist [data]="nameList" [filterable]="true" textField="companyName"
valueField="partyRoleId" formControlName="name" [valuePrimitive]="true" (ngModelChange)="modelChange($event)">
</kendo-dropdownlist>