I have the following component Template:
<div *ngFor="let ctrl of data; trackBy:ctrl?.Id">
<div *ngIf="getNext(ctrl.nextDate) | async as next">
<span>{{next | date: 'dd.MM.yyyy'}}</span>
</div>
</div>
getNext() is a simple method returning an Observable<Date>
:
public getNext(deadline: string): Observable<Date> {
return this.http.get<Date>(`${this.config.apiEndpoint}/api/meeting?deadline=${deadline}`);
}
My goal would be to invoke the method and subscribe to the observable with the async pipe in the template. However when I run the application endless GET and OPTIONS requests are generated.
Also if I place the method call outside the ngFor the same happen. The call would need to be executed inside the ngFor as the parameter is different for each collection item.
Why the method is simply called once and no more calls generated after the subscription?