mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Update Angular2Spa to current versions of Angular 2, angular2-universal-preview, etc.
This commit is contained in:
@@ -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 ngCore from 'angular2/core';
|
||||||
import * as ngRouter from 'angular2/router';
|
import * as ngRouter from 'angular2/router';
|
||||||
import * as ngUniversal from 'angular2-universal-preview';
|
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';
|
import { App } from './components/app/app';
|
||||||
|
|
||||||
export default function (params: any): Promise<{ html: string, globals?: any }> {
|
export default function (params: any): Promise<{ html: string, globals?: any }> {
|
||||||
const serverBindings = [
|
const serverBindings = [
|
||||||
ngRouter.ROUTER_BINDINGS,
|
ngRouter.ROUTER_BINDINGS,
|
||||||
ngUniversal.HTTP_PROVIDERS,
|
ngUniversal.HTTP_PROVIDERS,
|
||||||
ngUniversal.SERVER_LOCATION_PROVIDERS,
|
ngUniversal.NODE_LOCATION_PROVIDERS,
|
||||||
ngCore.provide(ngRouter.APP_BASE_HREF, { useValue: '/' }),
|
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 })
|
ngCore.provide(ngUniversal.REQUEST_URL, { useValue: params.url })
|
||||||
];
|
];
|
||||||
|
|
||||||
return ngUniversalRender.renderToString(App, serverBindings).then(html => {
|
return ngUniversal.renderDocument('<app />', App, serverBindings).then(html => {
|
||||||
return { html };
|
return { html };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,16 +7,14 @@ import { FetchData } from '../fetch-data/fetch-data';
|
|||||||
import { Counter } from '../counter/counter';
|
import { Counter } from '../counter/counter';
|
||||||
|
|
||||||
@ng.Component({
|
@ng.Component({
|
||||||
selector: 'app'
|
selector: 'app',
|
||||||
|
template: require('./app.html'),
|
||||||
|
directives: [NavMenu, router.ROUTER_DIRECTIVES]
|
||||||
})
|
})
|
||||||
@router.RouteConfig([
|
@router.RouteConfig([
|
||||||
{ path: '/', component: Home, name: 'Home' },
|
{ path: '/', component: Home, name: 'Home' },
|
||||||
{ path: '/counter', component: Counter, name: 'Counter' },
|
{ path: '/counter', component: Counter, name: 'Counter' },
|
||||||
{ path: '/fetch-data', component: FetchData, name: 'FetchData' }
|
{ path: '/fetch-data', component: FetchData, name: 'FetchData' }
|
||||||
])
|
])
|
||||||
@ng.View({
|
|
||||||
template: require('./app.html'),
|
|
||||||
directives: [NavMenu, router.ROUTER_DIRECTIVES]
|
|
||||||
})
|
|
||||||
export class App {
|
export class App {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import * as ng from 'angular2/core';
|
import * as ng from 'angular2/core';
|
||||||
|
|
||||||
@ng.Component({
|
@ng.Component({
|
||||||
selector: 'counter'
|
selector: 'counter',
|
||||||
})
|
|
||||||
@ng.View({
|
|
||||||
template: require('./counter.html')
|
template: require('./counter.html')
|
||||||
})
|
})
|
||||||
export class Counter {
|
export class Counter {
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ import * as ng from 'angular2/core';
|
|||||||
import { Http } from 'angular2/http';
|
import { Http } from 'angular2/http';
|
||||||
|
|
||||||
@ng.Component({
|
@ng.Component({
|
||||||
selector: 'fetch-data'
|
selector: 'fetch-data',
|
||||||
})
|
|
||||||
@ng.View({
|
|
||||||
template: require('./fetch-data.html')
|
template: require('./fetch-data.html')
|
||||||
})
|
})
|
||||||
export class FetchData {
|
export class FetchData {
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import * as ng from 'angular2/core';
|
import * as ng from 'angular2/core';
|
||||||
|
|
||||||
@ng.Component({
|
@ng.Component({
|
||||||
selector: 'home'
|
selector: 'home',
|
||||||
})
|
|
||||||
@ng.View({
|
|
||||||
template: require('./home.html')
|
template: require('./home.html')
|
||||||
})
|
})
|
||||||
export class Home {
|
export class Home {
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ import * as ng from 'angular2/core';
|
|||||||
import * as router from 'angular2/router';
|
import * as router from 'angular2/router';
|
||||||
|
|
||||||
@ng.Component({
|
@ng.Component({
|
||||||
selector: 'nav-menu'
|
selector: 'nav-menu',
|
||||||
})
|
|
||||||
@ng.View({
|
|
||||||
template: require('./nav-menu.html'),
|
template: require('./nav-menu.html'),
|
||||||
directives: [router.ROUTER_DIRECTIVES]
|
directives: [router.ROUTER_DIRECTIVES]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,18 +18,18 @@
|
|||||||
"webpack-hot-middleware": "^2.10.0"
|
"webpack-hot-middleware": "^2.10.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"angular2": "^2.0.0-beta.7",
|
"angular2": "2.0.0-beta.13",
|
||||||
"angular2-universal-preview": "^0.55.4",
|
"angular2-universal-preview": "^0.84.2",
|
||||||
"aspnet-prerendering": "^1.0.0",
|
"aspnet-prerendering": "^1.0.0",
|
||||||
"aspnet-webpack": "^1.0.1",
|
"aspnet-webpack": "^1.0.1",
|
||||||
"css": "^2.2.1",
|
"css": "^2.2.1",
|
||||||
"es6-shim": "^0.33.13",
|
"es6-shim": "^0.35.0",
|
||||||
"isomorphic-fetch": "^2.2.1",
|
"isomorphic-fetch": "^2.2.1",
|
||||||
"parse5": "^1.5.1",
|
"parse5": "^1.5.1",
|
||||||
"preboot": "^1.1.3",
|
"preboot": "^1.1.3",
|
||||||
"reflect-metadata": "^0.1.2",
|
"reflect-metadata": "0.1.2",
|
||||||
"rxjs": "^5.0.0-beta.2",
|
"rxjs": "5.0.0-beta.2",
|
||||||
"webpack-externals-plugin": "^1.0.0",
|
"webpack-externals-plugin": "^1.0.0",
|
||||||
"zone.js": "^0.5.15"
|
"zone.js": "^0.6.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
templates/Angular2Spa/typings/url-workaround.d.ts
vendored
Normal file
7
templates/Angular2Spa/typings/url-workaround.d.ts
vendored
Normal file
@@ -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 {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user