diff --git a/templates/AngularSpa/ClientApp/app/app.module.client.ts b/templates/AngularSpa/ClientApp/app/app.module.client.ts index ee77812..f5360ae 100644 --- a/templates/AngularSpa/ClientApp/app/app.module.client.ts +++ b/templates/AngularSpa/ClientApp/app/app.module.client.ts @@ -14,7 +14,8 @@ import { sharedConfig } from './app.module.shared'; ...sharedConfig.imports ], providers: [ - { provide: 'ORIGIN_URL', useValue: location.origin } + { provide: 'ORIGIN_URL', useValue: location.origin }, + { provide: 'PRERENDERING_DATA', useValue: (window as any).PRERENDERING_DATA } ] }) export class AppModule { diff --git a/templates/AngularSpa/ClientApp/app/components/fetchdata/fetchdata.component.html b/templates/AngularSpa/ClientApp/app/components/fetchdata/fetchdata.component.html index 8d24e71..1fadc50 100644 --- a/templates/AngularSpa/ClientApp/app/components/fetchdata/fetchdata.component.html +++ b/templates/AngularSpa/ClientApp/app/components/fetchdata/fetchdata.component.html @@ -1,5 +1,7 @@
Prerendering data: {{ prerenderingDataString }}
+This component demonstrates fetching data from the server.
Loading...
diff --git a/templates/AngularSpa/ClientApp/app/components/fetchdata/fetchdata.component.ts b/templates/AngularSpa/ClientApp/app/components/fetchdata/fetchdata.component.ts index 9c98b76..e49cf86 100644 --- a/templates/AngularSpa/ClientApp/app/components/fetchdata/fetchdata.component.ts +++ b/templates/AngularSpa/ClientApp/app/components/fetchdata/fetchdata.component.ts @@ -7,8 +7,11 @@ import { Http } from '@angular/http'; }) export class FetchDataComponent { public forecasts: WeatherForecast[]; + public prerenderingDataString: string; + + constructor(http: Http, @Inject('ORIGIN_URL') originUrl: string, @Inject('PRERENDERING_DATA') prerenderingData: any) { + this.prerenderingDataString = JSON.stringify(prerenderingData); - constructor(http: Http, @Inject('ORIGIN_URL') originUrl: string) { http.get(originUrl + '/api/SampleData/WeatherForecasts').subscribe(result => { this.forecasts = result.json() as WeatherForecast[]; }); diff --git a/templates/AngularSpa/ClientApp/boot-server.ts b/templates/AngularSpa/ClientApp/boot-server.ts index 08474cf..3fbe2ba 100644 --- a/templates/AngularSpa/ClientApp/boot-server.ts +++ b/templates/AngularSpa/ClientApp/boot-server.ts @@ -11,7 +11,8 @@ enableProdMode(); export default createServerRenderer(params => { const providers = [ { provide: INITIAL_CONFIG, useValue: { document: '