I want to return the result of a function in my component into a dropdown options:
this is my template:
<th>
<p-dropdown
[options]="getNames()"
[required]="true"
optionLabel="label"
(onChange)="filterName($event.target.value)"
>
</p-dropdown>
this is my function
public getNames() {
let namesLabels: any[];
this.backendService.getNames().subscribe(response => {
this.namesSelect = response.filter(item => item.name !== '');
this.namesSelect .forEach(prod => namesLabels.push(prod.name));
});
return namesLabels;
}
the array namesLabels is well charged, means when I add a console.info for each element of namesLabels I found my wanted result
in the screen I don't found any value in the dropdown, any help please ?