I have the following code inside an Angular application, the html looks like so.
<ng-multiselect-dropdown
(onSelect)="onSubstringSelect($event)">
</ng-multiselect-dropdown>
That onSubstringSelect is in the .ts part of the component:
onSubstringSelect(item: any) {
const dataPois = this.getPois(data);
alert("2nd alert " + dataPois);
// etc
}
getPois(data): any[] {
this.api.getPois(data).subscribe((result: any) => {
alert("1st alert");
return result.pois;
}
}, (error: any) => {
console.error('error', error);
return {};
});
return null;
}
I was expecing that I had first the alert("1st alert"); and then alert("2nd alert " + dataPois); but that alert is executing first. Why?
onSubstringSelectcalled?