How to use the angular2-universal.NODE_HTTP_PROVIDERS function in angular2-universal

To help you get started, we’ve selected a few angular2-universal 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 dotnet / aspnetcore / samples / angular / MusicStore / wwwroot / ng-app / boot-server.ts View on Github external
export default function (params: any): Promise<{ html: string, globals?: any }> {
    const serverBindings = [
        ngCore.provide(BASE_URL, { useValue: '/' }),
        ngCore.provide(ORIGIN_URL, { useValue: params.origin }),
        ngCore.provide(REQUEST_URL, { useValue: params.url }),
        ngUniversal.NODE_HTTP_PROVIDERS,
        ngUniversal.NODE_ROUTER_PROVIDERS,
        FormBuilder
    ];
    
    return ngUniversal.bootloader({
        directives: [App],
        providers: serverBindings,
        async: true,
        preboot: false,
        // TODO: Render just the  component instead of wrapping it inside an extra HTML document
        // Waiting on https://github.com/angular/universal/issues/347
        template: '\n'
    }).serializeApplication().then(html => {
        return { html };
    });
}