Description
I've got a connectionString
(called ApiHost
in this case) in appsettings.json
that I need my Angular app to know about. Right now, I'm just trying to make that string show up in the home
component, or anywhere as part of the Angular app.
I've figured out how to get that information on the c# side of things, but I don't know how to transfer that information down to the app.
I've tried to pass it down through the "TransferData concept":
(HomeController.cs:45) - pass info to "transferData concept"
var prerenderResult = await Prerenderer.RenderToString(
"/",
nodeServices,
new JavaScriptModuleExport(applicationBasePath + "/Client/dist/main-server"),
unencodedAbsoluteUrl,
unencodedPathAndQuery,
new { ApiHost = Configuration.GetConnectionString("ApiHost") },
30000,
Request.PathBase.ToString()
);
(main.server.aot.ts/main.server.ts:28) - create a script from ALL params
return ngAspnetCoreEngine(setupOptions).then(response => {
// Apply your transferData to response.globals
response.globals.transferData = createTransferScript(params.data);
This data shows up in window.TRANSFER_DATA['ApiHost']
. I can't figure out how to get access to this data, since Angular Universal doesn't allow access to window
.
I tried to inject TransferHttp
from TransferHttpModule
to call getFromCache(key): any
but it is considered private
.
What's the expected way to transfer data to the Angular app in this project?