angular / universal-starter

Angular Universal starter kit by @AngularClass
2.02k stars 688 forks source link

ssr rerender dont wait until the second round of callbacks / async #665

Open aiqoo opened 5 years ago

aiqoo commented 5 years ago

Bug Report

I run into a problem when I attempt to prerender a dynamic page that uses the returned data from a service using a JSON file.

It seems it does not wait until the second round of callbacks / async actions are done and rerenders a version without the data that is returned from the service.

in constructor...

this._articlesService.getArticleData(this.articleID).subscribe(
            (data) => {
                this.articleSettings = data;
                //console.log(data);
                this.articlesInitOnStart();
            },
            (err) => {
                console.log(err);
            }
        );

in ArticlesService....

getArticleData(articleID: number): Observable<any> {

        return this.httpClient.get<any>("./assets/data/articles/" + articleID + ".json")
            .pipe(catchError(this.handleError));
    }

What modules are related to this issue?

- [ +] express-engine

Environment:

Package Version

@angular-devkit/architect 0.12.4 @angular-devkit/build-angular 0.12.4 @angular-devkit/build-optimizer 0.12.4 @angular-devkit/build-webpack 0.12.4 @angular-devkit/core 7.2.4 @angular-devkit/schematics 7.2.4 @ngtools/webpack 7.2.4 @schematics/angular 7.2.4 @schematics/update 0.12.4 rxjs 6.3.3 typescript 3.2.4 webpack 4.28.4

node --version: v10.14.0 npm --version: 6.7.0. Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?) -->