mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 19:17:30 +00:00
Update Angular2Spa to current versions of Angular 2, angular2-universal-preview, etc.
This commit is contained in:
@@ -1,22 +1,20 @@
|
||||
import 'angular2-universal-preview/dist/server/universal-polyfill.js';
|
||||
import 'angular2-universal-polyfills';
|
||||
import * as ngCore from 'angular2/core';
|
||||
import * as ngRouter from 'angular2/router';
|
||||
import * as ngUniversal from 'angular2-universal-preview';
|
||||
import { BASE_URL } from 'angular2-universal-preview/dist/server/src/http/node_http';
|
||||
import * as ngUniversalRender from 'angular2-universal-preview/dist/server/src/render';
|
||||
import { App } from './components/app/app';
|
||||
|
||||
export default function (params: any): Promise<{ html: string, globals?: any }> {
|
||||
const serverBindings = [
|
||||
ngRouter.ROUTER_BINDINGS,
|
||||
ngUniversal.HTTP_PROVIDERS,
|
||||
ngUniversal.SERVER_LOCATION_PROVIDERS,
|
||||
ngUniversal.NODE_LOCATION_PROVIDERS,
|
||||
ngCore.provide(ngRouter.APP_BASE_HREF, { useValue: '/' }),
|
||||
ngCore.provide(BASE_URL, { useValue: params.absoluteUrl }),
|
||||
ngCore.provide(ngUniversal.BASE_URL, { useValue: params.absoluteUrl }),
|
||||
ngCore.provide(ngUniversal.REQUEST_URL, { useValue: params.url })
|
||||
];
|
||||
|
||||
return ngUniversalRender.renderToString(App, serverBindings).then(html => {
|
||||
return ngUniversal.renderDocument('<app />', App, serverBindings).then(html => {
|
||||
return { html };
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user