[Solved] Know when an angular HTTP call is done


In my eyes, the clean way would be to wait until ngOnInit and then do it the way @Christian Scillitoe showed. It´s also the easiest way here.

this.pointService.index().subscribe(x => {
    this.points = x.map(y => Point.fromJson(y)

    // Rest of initialization
}));

If you really really really want to kickof the request 5 Milliseconds up front, than you CAN put it in the constructor, but then you have “save” the observable (for example in a BehaviorSubject) and then catch it in ngOnInit().
You HAVE to use something like an observable item (or a promise), because you can´t know how long the http Request will take.

Possible to do it in the constructor, but why breaking through walls, when there is a big door near?

warm regards.

0

solved Know when an angular HTTP call is done