diff --git a/templates/Angular2Spa/ClientApp/boot-client.ts b/templates/Angular2Spa/ClientApp/boot-client.ts index 50f7181..be3ca22 100644 --- a/templates/Angular2Spa/ClientApp/boot-client.ts +++ b/templates/Angular2Spa/ClientApp/boot-client.ts @@ -5,11 +5,16 @@ import './styles/site.css'; import { bootstrap } from '@angular/platform-browser-dynamic'; import { FormBuilder } from '@angular/common'; -import * as router from '@angular/router-deprecated'; -import { Http, HTTP_PROVIDERS } from '@angular/http'; +import { provideRouter } from '@angular/router'; +import { HTTP_PROVIDERS } from '@angular/http'; import { App } from './components/app/app'; +import { routes } from './routes'; -bootstrap(App, [router.ROUTER_PROVIDERS, HTTP_PROVIDERS, FormBuilder]); +bootstrap(App, [ + ...HTTP_PROVIDERS, + FormBuilder, + provideRouter(routes) +]); // Basic hot reloading support. Automatically reloads and restarts the Angular 2 app each time // you modify source files. This will not preserve any application state other than the URL. diff --git a/templates/Angular2Spa/ClientApp/boot-server.ts b/templates/Angular2Spa/ClientApp/boot-server.ts index 959b90e..3549263 100644 --- a/templates/Angular2Spa/ClientApp/boot-server.ts +++ b/templates/Angular2Spa/ClientApp/boot-server.ts @@ -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 component instead of wrapping it inside an extra HTML document // Waiting on https://github.com/angular/universal/issues/347 diff --git a/templates/Angular2Spa/ClientApp/components/app/app.ts b/templates/Angular2Spa/ClientApp/components/app/app.ts index be0e694..d6fc8b9 100644 --- a/templates/Angular2Spa/ClientApp/components/app/app.ts +++ b/templates/Angular2Spa/ClientApp/components/app/app.ts @@ -1,20 +1,11 @@ import * as ng from '@angular/core'; -import * as router from '@angular/router-deprecated'; -import { Http, HTTP_BINDINGS } from '@angular/http'; +import { ROUTER_DIRECTIVES } from '@angular/router'; import { NavMenu } from '../nav-menu/nav-menu'; -import { Home } from '../home/home'; -import { FetchData } from '../fetch-data/fetch-data'; -import { Counter } from '../counter/counter'; @ng.Component({ selector: 'app', template: require('./app.html'), - directives: [NavMenu, router.ROUTER_DIRECTIVES] + directives: [...ROUTER_DIRECTIVES, NavMenu] }) -@router.RouteConfig([ - { path: '/', component: Home, name: 'Home' }, - { path: '/counter', component: Counter, name: 'Counter' }, - { path: '/fetch-data', component: FetchData, name: 'FetchData' } -]) export class App { } diff --git a/templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.html b/templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.html index 7130eda..4926cb8 100644 --- a/templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.html +++ b/templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.html @@ -7,23 +7,23 @@ - WebApplicationBasic + WebApplicationBasic