Reputation: 35
I'm new to angular2 (and angular overall) and I'm trying to envision how to integrate angular components with a legacy java app. I'm trying to build a transition path to a SPA like experience, and that means for some time I need to blend the tech stacks.
Specifically, I'm wondering if I were to include a root angular 2 component on a page how I could inject a static JavaScript object into it to (as opposed to building a back end api to serve that data).
For example, I envision something like:
<body>
<my-app [appContext]=appContext>
<\body>
I know that can't work, but I'm not sure how else to ask. I think during that app loading phase when we bind the angular component to the dom element we might be able to inject a JavaScript object into the my-app class. Either that or perhaps the my-app class can access a globally scoped JavaScript object that's declared outside of angular?
Upvotes: 2
Views: 1020
Reputation: 657751
you can assign the value to a global property window.appContext
and read it from within Angular2 or pass it as provider
How to pass parameters rendered from backend to angular2 bootstrap method
Upvotes: 1