(
moduleType: Type<T>,
options: {
document?: string | Document;
url?: string;
extraProviders?: StaticProvider[];
allowedHosts?: Readonly<string>[];
},
)
| 281 | * @publicApi |
| 282 | */ |
| 283 | export async function renderModule<T>( |
| 284 | moduleType: Type<T>, |
| 285 | options: { |
| 286 | document?: string | Document; |
| 287 | url?: string; |
| 288 | extraProviders?: StaticProvider[]; |
| 289 | allowedHosts?: Readonly<string>[]; |
| 290 | }, |
| 291 | ): Promise<string> { |
| 292 | const {document, url, extraProviders: platformProviders, allowedHosts} = options; |
| 293 | validateAllowedHosts(url, allowedHosts); |
| 294 | const platformRef = createServerPlatform({document, url, platformProviders}); |
| 295 | try { |
| 296 | const moduleRef = await platformRef.bootstrapModule(moduleType); |
| 297 | const applicationRef = moduleRef.injector.get(ApplicationRef); |
| 298 | |
| 299 | const measuringLabel = 'whenStable'; |
| 300 | startMeasuring(measuringLabel); |
| 301 | // Block until application is stable. |
| 302 | await applicationRef.whenStable(); |
| 303 | stopMeasuring(measuringLabel); |
| 304 | |
| 305 | return await renderInternal(platformRef, applicationRef); |
| 306 | } finally { |
| 307 | await asyncDestroyPlatform(platformRef); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Bootstraps an instance of an Angular application and renders it to a string. |
no test coverage detected
searching dependent graphs…