Update Angular 2 Music Store sample to latest Angular2/angular-universal and make HTTP requests work during server-side prerendering

This commit is contained in:
SteveSandersonMS
2016-04-21 11:59:01 +01:00
parent a0c47252ca
commit 7b53e4aa55
11 changed files with 52 additions and 19 deletions

View File

@@ -25,7 +25,11 @@ export class App {
public genres: models.Genre[];
constructor(http: Http) {
http.get('/api/genres/menu').subscribe(result => {
// Workaround for RC1 bug. This can be removed with ASP.NET Core 1.0 RC2.
let isServerSide = typeof window === 'undefined';
let options: any = isServerSide ? { headers: { Connection: 'keep-alive' } } : null;
http.get('/api/genres/menu', options).subscribe(result => {
this.genres = result.json();
});
}