Issue getting pre-rendered data into angular #420

Closed
opened 2025-08-09 17:16:13 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @avarndell on 9/15/2017

Trying to get angular to see the pre-rendered data.

in my Index.html (HomeController) I have the pre-render data loading.

Using DI in asp.net core the viewdata is being passed in with values.

In the boot.server.ts, I have the following
return new Promise((resolve, reject) => {
zone.onError.subscribe((errorInfo: any) => reject(errorInfo));
appRef.isStable.first(isStable => isStable).subscribe(() => {
// Because 'onStable' fires before 'onError', we have to delay slightly before
// completing the request in case there's an error to report
setImmediate(() => {
resolve({
html: state.renderToString(),
globals: {
apiUri: params.data.ApiUri,
grantType: params.data.GrantType,
tokenEndpoint: params.data.TokenEndpoint
}
});
moduleRef.destroy();
});
});
});
I can't seem to get a hold of the "globals" and it's properties.

*Originally created by @avarndell on 9/15/2017* Trying to get angular to see the pre-rendered data. in my Index.html (HomeController) I have the pre-render data loading. <div id="my-spa" asp-ng2-prerender-module="ClientApp/boot-server" asp-prerender-data="new { ApiUri = @ViewData["ApiUri"], GrantType = @ViewData["GrantType"], Token = @ViewData["TokenEndpoint"] }"></div> Using DI in asp.net core the viewdata is being passed in with values. In the boot.server.ts, I have the following return new Promise<RenderResult>((resolve, reject) => { zone.onError.subscribe((errorInfo: any) => reject(errorInfo)); appRef.isStable.first(isStable => isStable).subscribe(() => { // Because 'onStable' fires before 'onError', we have to delay slightly before // completing the request in case there's an error to report setImmediate(() => { resolve({ html: state.renderToString(), globals: { apiUri: params.data.ApiUri, grantType: params.data.GrantType, tokenEndpoint: params.data.TokenEndpoint } }); moduleRef.destroy(); }); }); }); I can't seem to get a hold of the "globals" and it's properties.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#420
No description provided.