(
moduleType: Type<T>,
options: {
document?: string | Document;
url?: string;
extraProviders?: StaticProvider[];
allowedHosts?: Readonly<string>[];
},
)
| 320 | * @publicApi |
| 321 | */ |
| 322 | export async function renderModule<T>( |
| 323 | moduleType: Type<T>, |
| 324 | options: { |
| 325 | document?: string | Document; |
| 326 | url?: string; |
| 327 | extraProviders?: StaticProvider[]; |
| 328 | allowedHosts?: Readonly<string>[]; |
| 329 | }, |
| 330 | ): Promise<string> { |
| 331 | const {document, url, extraProviders: platformProviders, allowedHosts} = options; |
| 332 | validateAllowedHosts(url, allowedHosts); |
| 333 | const platformRef = createServerPlatform({document, url, platformProviders}); |
| 334 | try { |
| 335 | const moduleRef = await platformRef.bootstrapModule(moduleType); |
| 336 | if (platformRef.destroyed || moduleRef.injector.destroyed) { |
| 337 | return ''; |
| 338 | } |
| 339 | const applicationRef = moduleRef.injector.get(ApplicationRef); |
| 340 | |
| 341 | const measuringLabel = 'whenStable'; |
| 342 | startMeasuring(measuringLabel); |
| 343 | // Block until application is stable. |
| 344 | await applicationRef.whenStable(); |
| 345 | stopMeasuring(measuringLabel); |
| 346 | |
| 347 | return await renderInternal(platformRef, applicationRef); |
| 348 | } finally { |
| 349 | await asyncDestroyPlatform(platformRef); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Bootstraps an instance of an Angular application and renders it to a string. |
no test coverage detected