-
Notifications
You must be signed in to change notification settings - Fork 519
Accessing globals from pre-rendering #253
Comments
Sounds like you're trying to access If you want some client-only code to access this data, wrap it in a guard clause like this, so that it doesn't throw any exception while running on the server:
If you want to share some .NET-supplied data with your server-side JavaScript code, you can pass it to the boot module using the |
@SteveSandersonMS Is there a way / example of making the component prerender on the server with the data passed to it from the At the moment I'm trying to set it from the client side using |
Any data you pass via In Angular 2, you could use the DI system to make it available with some arbitrary key, e.g., by adding this to the
... and then receiving this as a constructor parameter in a component:
You'd also have to supply some value (or null or whatever) for |
Hi, But the issue is when the boot-client bootstraps the app it overrides the provider data injected in the constructor. |
@abhilash1990 If you think you've found a problem, could you report it as a new issue? This issue was about something else and in any case is closed now :) |
Hi Steve, Can we use this for sending the Appsettings from server to client side also ? |
Hi,
I've followed the steps in the documentation to put server prerendered data into an Angular 2 application.
However, even though I can see that the data is available in the window (through the console), components can't seem to access the window like in the example i.e.
window.userData
. When this is attempted the application complains saying that thewindow is not defined
.Are we meant to access the pre-rendered data in another way?
The text was updated successfully, but these errors were encountered: