mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 19:17:30 +00:00
Upgrade Angular template to Angular 2 RC3 and migrate to new @angular/router
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
import 'angular2-universal/polyfills';
|
||||
import * as ngCore from '@angular/core';
|
||||
import { APP_BASE_HREF } from '@angular/common';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import * as ngUniversal from 'angular2-universal';
|
||||
import { BASE_URL, ORIGIN_URL, REQUEST_URL } from 'angular2-universal/common';
|
||||
import { App } from './components/app/app';
|
||||
import { routes } from './routes';
|
||||
|
||||
const bootloader = ngUniversal.bootloader({
|
||||
async: true,
|
||||
preboot: false,
|
||||
platformProviders: [
|
||||
ngCore.provide(BASE_URL, { useValue: '/' })
|
||||
ngCore.provide(APP_BASE_HREF, { useValue: '/' }),
|
||||
]
|
||||
});
|
||||
|
||||
@@ -16,11 +19,11 @@ export default function (params: any): Promise<{ html: string, globals?: any }>
|
||||
const config: ngUniversal.AppConfig = {
|
||||
directives: [App],
|
||||
providers: [
|
||||
ngCore.provide(REQUEST_URL, { useValue: params.url }),
|
||||
ngCore.provide(ORIGIN_URL, { useValue: params.origin }),
|
||||
...ngUniversal.NODE_PLATFORM_PIPES,
|
||||
...ngUniversal.NODE_ROUTER_PROVIDERS,
|
||||
ngCore.provide(REQUEST_URL, { useValue: params.url }),
|
||||
...ngUniversal.NODE_HTTP_PROVIDERS,
|
||||
provideRouter(routes),
|
||||
...ngUniversal.NODE_LOCATION_PROVIDERS,
|
||||
],
|
||||
// TODO: Render just the <app> component instead of wrapping it inside an extra HTML document
|
||||
// Waiting on https://github.com/angular/universal/issues/347
|
||||
|
||||
Reference in New Issue
Block a user