How to use the angular2-universal-preview.BASE_URL function in angular2-universal-preview

To help you get started, we’ve selected a few angular2-universal-preview 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 / src / Microsoft.AspNet.AngularServices / Content / Node / angular-rendering.js View on Github external
renderToString: function(callback, options) {
        try {
            var component = findAngularComponent(options);
            var serverBindings = [
                ngRouter.ROUTER_BINDINGS,
                ngUniversal.HTTP_PROVIDERS,
                ngCore.provide(ngUniversal.BASE_URL, { useValue: options.requestUrl }),
                ngCore.provide(ngRouter.APP_BASE_HREF, { useValue: '/' }),
                ngUniversal.SERVER_LOCATION_PROVIDERS
            ];

            return ngUniversalRender.renderToString(component, serverBindings).then(
                function(successValue) { callback(null, successValue); },
                function(errorValue) { callback(errorValue); }
            );
        } catch (synchronousException) {
            callback(synchronousException);
        }
    }
};