I am currently using ng-prime's <p-autocomplete>
to display values by searching in the back-end.
Below is the HTML code I have implemented:
<p-autoComplete [(ngModel)]="agent" [suggestions]="filteredAgents" name="agents" (completeMethod)="filterAgents($event)" [size]="10"
placeholder="Agents" [minLength]="3"></p-autoComplete>
Within the component.ts file, I initialize the array at the start of the component like this:
filteredAgents: string[] = [];
I also have a method that sends queries to the back end and then adds them to the array:
filterAgents(event) {
let query = event.query;
this._agentsService.getAgentSearch(query).subscribe(result => {
result.items.forEach((value) => {
this.filteredAgents.push(value.name);
console.log(this.filteredAgents);
});
});
}
While I can see the filtered values in the console, they are not showing up in the suggestions. What could be causing this issue?