I'm hoping someone familiar with ng2's dynamic component and templates, will be able to help me with an unusual problem. I want to know how to render dynamic created components using ONLY AND EXCLUSIVELY TEMPLATE markup. For instance:
I created all my dynamic components (lets say FooBarComponent) in app-editor.component using Angular's ComponentResolver.resolveComponent. So I have:
app-editor.component.ts
public instances : Array<ComponentFactory>;
Ok, so far so good. It works the way I want. All instances of components are working as expected. Each one's model set properly.
Now I need to display, lets say, two of these components instances in my view. What should I do?
app-editor.template.ts
<div>
<foo-bar instance-index="2"></foo-bar>
<foo-bar instance-index="15"></foo-bar>
</div>
Remember: I would like to wire the instances to the view using exclusively template markup. I know I could be using @ViewChild in the app-editor.component and set a view variable in app-editor.template then call some loadIntoLocation | loadAsRoot methods to insert component to the DOM, but to me, it sounds like jQuery way of do things, isn't?