diff --git a/templates/Angular2Spa/ClientApp/boot-server.ts b/templates/Angular2Spa/ClientApp/boot-server.ts index b93922a..5847f94 100644 --- a/templates/Angular2Spa/ClientApp/boot-server.ts +++ b/templates/Angular2Spa/ClientApp/boot-server.ts @@ -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, serverBindings).then(html => { return { html }; }); } diff --git a/templates/Angular2Spa/ClientApp/components/app/app.ts b/templates/Angular2Spa/ClientApp/components/app/app.ts index 7d6b48f..fd88d1f 100644 --- a/templates/Angular2Spa/ClientApp/components/app/app.ts +++ b/templates/Angular2Spa/ClientApp/components/app/app.ts @@ -7,16 +7,14 @@ import { FetchData } from '../fetch-data/fetch-data'; import { Counter } from '../counter/counter'; @ng.Component({ - selector: 'app' + selector: 'app', + template: require('./app.html'), + directives: [NavMenu, router.ROUTER_DIRECTIVES] }) @router.RouteConfig([ { path: '/', component: Home, name: 'Home' }, { path: '/counter', component: Counter, name: 'Counter' }, { path: '/fetch-data', component: FetchData, name: 'FetchData' } ]) -@ng.View({ - template: require('./app.html'), - directives: [NavMenu, router.ROUTER_DIRECTIVES] -}) export class App { } diff --git a/templates/Angular2Spa/ClientApp/components/counter/counter.ts b/templates/Angular2Spa/ClientApp/components/counter/counter.ts index 8bf2a28..aaf03fe 100644 --- a/templates/Angular2Spa/ClientApp/components/counter/counter.ts +++ b/templates/Angular2Spa/ClientApp/components/counter/counter.ts @@ -1,9 +1,7 @@ import * as ng from 'angular2/core'; @ng.Component({ - selector: 'counter' -}) -@ng.View({ + selector: 'counter', template: require('./counter.html') }) export class Counter { diff --git a/templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts b/templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts index 2303697..96f8fc4 100644 --- a/templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts +++ b/templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts @@ -2,9 +2,7 @@ import * as ng from 'angular2/core'; import { Http } from 'angular2/http'; @ng.Component({ - selector: 'fetch-data' -}) -@ng.View({ + selector: 'fetch-data', template: require('./fetch-data.html') }) export class FetchData { diff --git a/templates/Angular2Spa/ClientApp/components/home/home.ts b/templates/Angular2Spa/ClientApp/components/home/home.ts index 0ec3ef1..2561977 100644 --- a/templates/Angular2Spa/ClientApp/components/home/home.ts +++ b/templates/Angular2Spa/ClientApp/components/home/home.ts @@ -1,9 +1,7 @@ import * as ng from 'angular2/core'; @ng.Component({ - selector: 'home' -}) -@ng.View({ + selector: 'home', template: require('./home.html') }) export class Home { diff --git a/templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.ts b/templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.ts index 938f2fe..7eb6aa8 100644 --- a/templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.ts +++ b/templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.ts @@ -2,9 +2,7 @@ import * as ng from 'angular2/core'; import * as router from 'angular2/router'; @ng.Component({ - selector: 'nav-menu' -}) -@ng.View({ + selector: 'nav-menu', template: require('./nav-menu.html'), directives: [router.ROUTER_DIRECTIVES] }) diff --git a/templates/Angular2Spa/package.json b/templates/Angular2Spa/package.json index 47bc7a3..0a2715a 100644 --- a/templates/Angular2Spa/package.json +++ b/templates/Angular2Spa/package.json @@ -18,18 +18,18 @@ "webpack-hot-middleware": "^2.10.0" }, "dependencies": { - "angular2": "^2.0.0-beta.7", - "angular2-universal-preview": "^0.55.4", + "angular2": "2.0.0-beta.13", + "angular2-universal-preview": "^0.84.2", "aspnet-prerendering": "^1.0.0", "aspnet-webpack": "^1.0.1", "css": "^2.2.1", - "es6-shim": "^0.33.13", + "es6-shim": "^0.35.0", "isomorphic-fetch": "^2.2.1", "parse5": "^1.5.1", "preboot": "^1.1.3", - "reflect-metadata": "^0.1.2", - "rxjs": "^5.0.0-beta.2", + "reflect-metadata": "0.1.2", + "rxjs": "5.0.0-beta.2", "webpack-externals-plugin": "^1.0.0", - "zone.js": "^0.5.15" + "zone.js": "^0.6.6" } } diff --git a/templates/Angular2Spa/typings/url-workaround.d.ts b/templates/Angular2Spa/typings/url-workaround.d.ts new file mode 100644 index 0000000..9d16760 --- /dev/null +++ b/templates/Angular2Spa/typings/url-workaround.d.ts @@ -0,0 +1,7 @@ +// This file is a workaround for angular2-universal-preview version 0.84.2 relying on the declaration of +// Node's 'url' module. Ideally it would not declare dependencies on Node APIs except where it also supplies +// the definitions itself. + +declare module 'url' { + export interface Url {} +}