angular universal app performance, APP_BOOTSTRAP_LISTENER, flicker

后端 未结 1 1834
生来不讨喜
生来不讨喜 2021-01-14 23:42
Angular 4.4.6
Angular CLI 1.3.2
Node 6.x.x
NPM 3.10.10
Webpack 3.4.1

In Angular Universal application when server view sift to client view there is

相关标签:
1条回答
  • 2021-01-15 00:18

    Edit: this solution is for angular 5

    When I had the flickering problem I just added BrowserTransferStateModule to the client app

    //app.module.ts
    import {BrowserModule, BrowserTransferStateModule} from '@angular/platform-browser';
    imports: [
    //...
    BrowserModule.withServerTransition({appId: 'my-app'}),
    BrowserTransferStateModule,
    

    then ServerTransferStateModule to the server app

    //app.server.module.ts
    import {ServerModule, ServerTransferStateModule} from '@angular/platform-server';
    
    //...
     imports: [
    AppModule,
    ServerModule,
    ServerTransferStateModule
    

    And I modified main.ts to boostrap the app once the dom is loaded

    //main.ts
    document.addEventListener('DOMContentLoaded', () => {
      platformBrowserDynamic().bootstrapModule(AppModule)
    .catch(err => console.log(err));
    });
    

    I did not use APP_BOOTSTRAP_LISTENER like you did (not sure if it makes a difference)

    0 讨论(0)
提交回复
热议问题