Update Angular2Spa to current versions of Angular 2, angular2-universal-preview, etc.

This commit is contained in:
SteveSandersonMS
2016-03-31 16:41:24 +01:00
parent 033a42ab42
commit 89c8dd3b36
8 changed files with 24 additions and 29 deletions

View File

@@ -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 };
});
}