mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 18:19:40 +00:00
Example of using asp-prerender-data to get server-supplied data to both server and client JS
This commit is contained in:
@@ -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[];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user