S
S
Saharman2019-04-06 21:09:21
Angular
Saharman, 2019-04-06 21:09:21

How to load an Angular component only after making a request to the server?

I have a component. When it is called, a get request occurs (for example, from a constructor or ngOnInit). It turns out that while we are waiting for the results of this request (executing code from subscribe), our component is already displayed on the user's page. How can I make the component not render until the request ends and the result of the request has been processed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
msdosx86, 2019-04-09
@msdosx86

<app-component *ngIf="show"></app-component>

public show: boolean;
this.doRequest().subscribe(() => this.show = true));

I
ingwar4ik, 2019-04-07
@ingwar4ik

Look towards Resolve

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question