How to use the @angular/platform-server.PlatformState function in @angular/platform-server

To help you get started, we’ve selected a few @angular/platform-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marclaval / optimize-angular-app / scripts / prerender.js View on Github external
platform.bootstrapModule(prerenderModule.AppModule).then(moduleRef => {
  const state = moduleRef.injector.get(ps.PlatformState);
  const appRef = moduleRef.injector.get(co.ApplicationRef);

  appRef._isStable
    .filter((isStable) => isStable)
    .first()
    .subscribe((stable) => {
      try {
        fs.mkdirSync('./tmp/prerender');
      }
      catch(e){}
      fs.writeFileSync('./tmp/prerender/index.html', state.renderToString(), 'utf-8');
      platform.destroy();
    });
});
github AngularClass / angular-universal-transfer-state / src / server.ngfactory.ts View on Github external
([] as any[]),(_l:any) => {
      return i0.ɵmod([i0.ɵmpd(512,i0.ComponentFactoryResolver,i0.ɵCodegenComponentFactoryResolver,
          [[8,([] as any[])],[3,i0.ComponentFactoryResolver],i0.NgModuleRef]),i0.ɵmpd(4608,
          i2.TransferState,i1.ServerTransferState,[i3.PlatformState,i0.RendererFactory2]),
          i0.ɵmpd(512,i1.ServerTransferStateModule,i1.ServerTransferStateModule,([] as any[]))]);
    });
//# sourceMappingURL=data:application/json;base64,eyJmaWxlIjoiL1VzZXJzL3BhdHJpY2tqcy9Db2RlL0FuZ3VsYXJDbGFzcy91bml2ZXJzYWwtdHJhbnNmZXItc3RhdGUvc3JjL3NlcnZlci5uZ2ZhY3RvcnkudHMiLCJ2ZXJzaW9uIjozLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJuZzovLy9Vc2Vycy9wYXRyaWNranMvQ29kZS9Bbmd1bGFyQ2xhc3MvdW5pdmVyc2FsLXRyYW5zZmVyLXN0YXRlL3NyYy9zZXJ2ZXIudHMiXSwic291cmNlc0NvbnRlbnQiOlsiICJdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ==