renderApplication
function
stable
Bootstraps an instance of an Angular application and renders it to a string.
API
function renderApplication(
bootstrap: ServerApplicationBootstrapFn,
options: {
document?: string | Document | undefined;
url?: string | undefined;
platformProviders?: Provider[] | undefined;
},
): Promise<string>;
renderApplication
Promise<string>
Bootstraps an instance of an Angular application and renders it to a string.
@parambootstrap
ServerApplicationBootstrapFn
A method that when invoked returns a promise that returns an ApplicationRef
instance once resolved. The method is invoked with an Injector
instance that
provides access to the platform-level dependency injection context.
@paramoptions
{ document?: string | Document | undefined; url?: string | undefined; platformProviders?: Provider[] | undefined; }
Additional configuration for the render operation:
document
- the document of the page to render, either as an HTML string or as a reference to thedocument
instance.url
- the URL for the current render request.platformProviders
- the platform level providers for the current render request.
@returns
Promise<string>
Usage Notes
import { renderApplication } from '@angular/platform-server';import { bootstrapServerApplication } from '@angular/platform-server';import { ApplicationConfig } from '@angular/core';import { AppComponent } from './app.component';const appConfig: ApplicationConfig = { providers: [...] };const bootstrap = bootstrapServerApplication(AppComponent, appConfig);const output = await renderApplication(bootstrap);
Jump to details