Template try to display data that not received from server [closed]

ngIf is a bad choice because that will hide your html till the response comes and you don’t want to have a hidden html in case of error for example. You can try using safe navigation ?

<h1 class="has-text-info"> Your Code: {{ desc?.codeName}} </h1>

and it’s possible to use async pipe if you want, no need to subscribe and unsubscribe

desc: Observable<Desc>;
this.desc = this.myService.getData(id).pipe(map(data => data.results));

<h1 class="has-text-info"> Your Code: {{ (desc | async)?.codeName}} </h1>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top