mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
Update Angular 2 Music Store sample to latest Angular 2 and other dependencies. Switch from asp-ng2-prerender-module to the more general asp-prerender-module.
This commit is contained in:
29
samples/angular/MusicStore/wwwroot/ng-app/boot-server.ts
Normal file
29
samples/angular/MusicStore/wwwroot/ng-app/boot-server.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'angular2-universal/polyfills';
|
||||
import { FormBuilder } from 'angular2/common';
|
||||
import * as ngCore from 'angular2/core';
|
||||
import * as ngRouter from 'angular2/router';
|
||||
import * as ngUniversal from 'angular2-universal';
|
||||
import { App } from './components/app/app';
|
||||
|
||||
export default function (params: any): Promise<{ html: string, globals?: any }> {
|
||||
const serverBindings = [
|
||||
ngCore.provide(ngUniversal.BASE_URL, { useValue: params.absoluteUrl }),
|
||||
ngCore.provide(ngUniversal.REQUEST_URL, { useValue: params.url }),
|
||||
ngCore.provide(ngRouter.APP_BASE_HREF, { useValue: '/' }),
|
||||
ngUniversal.NODE_HTTP_PROVIDERS,
|
||||
ngUniversal.NODE_ROUTER_PROVIDERS,
|
||||
FormBuilder
|
||||
];
|
||||
|
||||
return ngUniversal.bootloader({
|
||||
directives: [App],
|
||||
providers: serverBindings,
|
||||
async: true,
|
||||
preboot: false,
|
||||
// TODO: Render just the <app> component instead of wrapping it inside an extra HTML document
|
||||
// Waiting on https://github.com/angular/universal/issues/347
|
||||
template: '<!DOCTYPE html>\n<html><head></head><body><app></app></body></html>'
|
||||
}).serializeApplication().then(html => {
|
||||
return { html };
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user