Accessing globals from boot-server prerendering #1293

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

Originally created by @abhilash1990 on 10/25/2016

Hi,

In Angular 2 and Asp.Net core app, I am using the DI system to make some global data available with some arbitrary key, e.g., by adding this to the providers array in boot-server.ts:

ngCore.provide('myCustomKey', { useValue: params.data.yourValue }),
... and then receiving this as a constructor parameter in a component:

constructor(@ng.Inject('myCustomKey') myValue: any) {
// Do something with myVaue, e.g., prepopulate the component's data properties
}

After this i need to declare the same provide('myCustomKey', { useValue: params.data.yourValue }), in boot-client.ts otherwise application shows error - provider not available.

The issue is the data is coming in the pre-render but after a fraction of second it got overridden by the boot-client provider data.

Is there any way to get the pre-render data in boot-clien.ts?

*Originally created by @abhilash1990 on 10/25/2016* Hi, In Angular 2 and Asp.Net core app, I am using the DI system to make some global data available with some arbitrary key, e.g., by adding this to the providers array in boot-server.ts: ngCore.provide('myCustomKey', { useValue: params.data.yourValue }), ... and then receiving this as a constructor parameter in a component: constructor(@ng.Inject('myCustomKey') myValue: any) { // Do something with myVaue, e.g., prepopulate the component's data properties } After this i need to declare the same provide('myCustomKey', { useValue: params.data.yourValue }), in boot-client.ts otherwise application shows error - provider not available. The issue is the data is coming in the pre-render but after a fraction of second it got overridden by the boot-client provider data. Is there any way to get the pre-render data in boot-clien.ts?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1293
No description provided.