Patrick
Patrick

Reputation: 35

Injecting data into root component

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

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657751

Upvotes: 1

Related Questions