-1

I am currently experimenting with the Angular AsyncPipe in combination with ngIf. The observable in production comes from the HttpService, it is extended with a retry strategie for error handling.

The template looks like this:

<div *ngIf="(configuration$ | async) as configuration; else loading">
  <p>{{configuration}}</p>
</div>

<ng-template #loading>
  <p>Loading...</p>
</ng-template>

The retry strategie uses a dialog for the error and after the dialog is dimissed, the observable should be rerun.

If no error occurs the template is loading properly and everything works just fine. However, after the error occurs only one in the beginning and the user dismisses the dialog to start a retry the value is not properly shown in the template.

I included an example as well.

In the example I mock the HttpService from Angular to show the behaviour.

kkla320
  • 1
  • 1

1 Answers1

0

You are throwing an error at the beginning through observable.error. Change your logic or remove that.

public getConfiguration(): Observable<string> {
  return Observable.create((observer) => { 
      observer.next('Hello World.'); 
  });
}

Demo

Sachila Ranawaka
  • 39,756
  • 7
  • 56
  • 80
  • The example I provided is just an example to show the behavour I am experiencing. In production I use the HttpService which can throw the error in the beginning. – kkla320 Dec 28 '18 at 10:49