Use-case: A client wants to build a library that consist of Angular 2 components but exposes abstracted, technology-agnostic interface to the end user (developer) of that library, so that those users might be using plain JavaScript and not be aware of the internals of the library.
The difficulty comes from the following:
- There is a page, which uses plain JavaScript. This page is developed by third-party.
- The third-party should be able to insert given Angular 2 component at specific places (DOM nodes) on the page.
- Let's say the component is
<mg-input>
and it should be shown in the header of the plain JavaScript page, but not only there - also in a form down the page. Two different places, two different DOM nodes which have between them plain html.
The question: How do we bootstrap component at specific DOM node and how do we pass configuration (not primitives but a complex object) to those components?
In the React
world this is done simply by running ReactDom.render(domEl, <CustomInput nonPrimitiveConfig={config}/>)
and depending on what domEl
и config
is, the component will be rendered in different places with different config.
How to do this in Angular 2?