Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8423233

Browse filesBrowse files
Update to angular2-universal 0.103.0 and amend boot-server.ts to fix "there can only be one platform" issue
1 parent ce6cdfd commit 8423233
Copy full SHA for 8423233

File tree

Expand file treeCollapse file tree

2 files changed

+19
-18
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-18
lines changed
Open diff view settings
Collapse file
+18-17Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
import 'angular2-universal/polyfills';
22
import * as ngCore from '@angular/core';
3-
import * as ngRouter from '@angular/router-deprecated';
43
import * as ngUniversal from 'angular2-universal';
54
import { BASE_URL, ORIGIN_URL, REQUEST_URL } from 'angular2-universal/common';
65
import { App } from './components/app/app';
76

8-
export default function (params: any): Promise<{ html: string, globals?: any }> {
9-
const serverBindings = [
10-
ngCore.provide(BASE_URL, { useValue: '/' }),
11-
ngCore.provide(ORIGIN_URL, { useValue: params.origin }),
12-
ngCore.provide(REQUEST_URL, { useValue: params.url }),
13-
...ngUniversal.NODE_PLATFORM_PIPES,
14-
...ngUniversal.NODE_ROUTER_PROVIDERS,
15-
...ngUniversal.NODE_HTTP_PROVIDERS,
16-
];
7+
const bootloader = ngUniversal.bootloader({
8+
async: true,
9+
preboot: false,
10+
platformProviders: [
11+
ngCore.provide(BASE_URL, { useValue: '/' })
12+
]
13+
});
1714

18-
let bootloader = ngUniversal.bootloader({
15+
export default function (params: any): Promise<{ html: string, globals?: any }> {
16+
const config: ngUniversal.AppConfig = {
1917
directives: [App],
20-
componentProviders: serverBindings,
21-
async: true,
22-
preboot: false,
18+
providers: [
19+
ngCore.provide(REQUEST_URL, { useValue: params.url }),
20+
ngCore.provide(ORIGIN_URL, { useValue: params.origin }),
21+
...ngUniversal.NODE_PLATFORM_PIPES,
22+
...ngUniversal.NODE_ROUTER_PROVIDERS,
23+
...ngUniversal.NODE_HTTP_PROVIDERS,
24+
],
2325
// TODO: Render just the <app> component instead of wrapping it inside an extra HTML document
2426
// Waiting on https://github.com/angular/universal/issues/347
2527
template: '<!DOCTYPE html>\n<html><head></head><body><app></app></body></html>'
26-
});
28+
};
2729

28-
return bootloader.serializeApplication().then(html => {
29-
bootloader.dispose();
30+
return bootloader.serializeApplication(config).then(html => {
3031
return { html };
3132
});
3233
}
Collapse file

‎templates/Angular2Spa/package.json‎

Copy file name to clipboardExpand all lines: templates/Angular2Spa/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@angular/platform-server": "2.0.0-rc.1",
2828
"@angular/router": "2.0.0-rc.1",
2929
"@angular/router-deprecated": "2.0.0-rc.1",
30-
"angular2-universal": "0.100.3",
30+
"angular2-universal": "0.103.0",
3131
"aspnet-prerendering": "^1.0.2",
3232
"aspnet-webpack": "^1.0.1",
3333
"css": "^2.2.1",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.