Skip to content

Commit 89c8dd3

Browse files
Update Angular2Spa to current versions of Angular 2, angular2-universal-preview, etc.
1 parent 033a42a commit 89c8dd3

File tree

8 files changed

+24
-29
lines changed

8 files changed

+24
-29
lines changed
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import 'angular2-universal-preview/dist/server/universal-polyfill.js';
1+
import 'angular2-universal-polyfills';
22
import * as ngCore from 'angular2/core';
33
import * as ngRouter from 'angular2/router';
44
import * as ngUniversal from 'angular2-universal-preview';
5-
import { BASE_URL } from 'angular2-universal-preview/dist/server/src/http/node_http';
6-
import * as ngUniversalRender from 'angular2-universal-preview/dist/server/src/render';
75
import { App } from './components/app/app';
86

97
export default function (params: any): Promise<{ html: string, globals?: any }> {
108
const serverBindings = [
119
ngRouter.ROUTER_BINDINGS,
1210
ngUniversal.HTTP_PROVIDERS,
13-
ngUniversal.SERVER_LOCATION_PROVIDERS,
11+
ngUniversal.NODE_LOCATION_PROVIDERS,
1412
ngCore.provide(ngRouter.APP_BASE_HREF, { useValue: '/' }),
15-
ngCore.provide(BASE_URL, { useValue: params.absoluteUrl }),
13+
ngCore.provide(ngUniversal.BASE_URL, { useValue: params.absoluteUrl }),
1614
ngCore.provide(ngUniversal.REQUEST_URL, { useValue: params.url })
1715
];
1816

19-
return ngUniversalRender.renderToString(App, serverBindings).then(html => {
17+
return ngUniversal.renderDocument('<app />', App, serverBindings).then(html => {
2018
return { html };
2119
});
2220
}

templates/Angular2Spa/ClientApp/components/app/app.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ import { FetchData } from '../fetch-data/fetch-data';
77
import { Counter } from '../counter/counter';
88

99
@ng.Component({
10-
selector: 'app'
10+
selector: 'app',
11+
template: require('./app.html'),
12+
directives: [NavMenu, router.ROUTER_DIRECTIVES]
1113
})
1214
@router.RouteConfig([
1315
{ path: '/', component: Home, name: 'Home' },
1416
{ path: '/counter', component: Counter, name: 'Counter' },
1517
{ path: '/fetch-data', component: FetchData, name: 'FetchData' }
1618
])
17-
@ng.View({
18-
template: require('./app.html'),
19-
directives: [NavMenu, router.ROUTER_DIRECTIVES]
20-
})
2119
export class App {
2220
}

templates/Angular2Spa/ClientApp/components/counter/counter.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import * as ng from 'angular2/core';
22

33
@ng.Component({
4-
selector: 'counter'
5-
})
6-
@ng.View({
4+
selector: 'counter',
75
template: require('./counter.html')
86
})
97
export class Counter {

templates/Angular2Spa/ClientApp/components/fetch-data/fetch-data.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import * as ng from 'angular2/core';
22
import { Http } from 'angular2/http';
33

44
@ng.Component({
5-
selector: 'fetch-data'
6-
})
7-
@ng.View({
5+
selector: 'fetch-data',
86
template: require('./fetch-data.html')
97
})
108
export class FetchData {

templates/Angular2Spa/ClientApp/components/home/home.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import * as ng from 'angular2/core';
22

33
@ng.Component({
4-
selector: 'home'
5-
})
6-
@ng.View({
4+
selector: 'home',
75
template: require('./home.html')
86
})
97
export class Home {

templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import * as ng from 'angular2/core';
22
import * as router from 'angular2/router';
33

44
@ng.Component({
5-
selector: 'nav-menu'
6-
})
7-
@ng.View({
5+
selector: 'nav-menu',
86
template: require('./nav-menu.html'),
97
directives: [router.ROUTER_DIRECTIVES]
108
})

templates/Angular2Spa/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
"webpack-hot-middleware": "^2.10.0"
1919
},
2020
"dependencies": {
21-
"angular2": "^2.0.0-beta.7",
22-
"angular2-universal-preview": "^0.55.4",
21+
"angular2": "2.0.0-beta.13",
22+
"angular2-universal-preview": "^0.84.2",
2323
"aspnet-prerendering": "^1.0.0",
2424
"aspnet-webpack": "^1.0.1",
2525
"css": "^2.2.1",
26-
"es6-shim": "^0.33.13",
26+
"es6-shim": "^0.35.0",
2727
"isomorphic-fetch": "^2.2.1",
2828
"parse5": "^1.5.1",
2929
"preboot": "^1.1.3",
30-
"reflect-metadata": "^0.1.2",
31-
"rxjs": "^5.0.0-beta.2",
30+
"reflect-metadata": "0.1.2",
31+
"rxjs": "5.0.0-beta.2",
3232
"webpack-externals-plugin": "^1.0.0",
33-
"zone.js": "^0.5.15"
33+
"zone.js": "^0.6.6"
3434
}
3535
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This file is a workaround for angular2-universal-preview version 0.84.2 relying on the declaration of
2+
// Node's 'url' module. Ideally it would not declare dependencies on Node APIs except where it also supplies
3+
// the definitions itself.
4+
5+
declare module 'url' {
6+
export interface Url {}
7+
}

0 commit comments

Comments
 (0)