Is it possible to dynamically load a component in Angular 2 using a selector ?
Let's say we have a component like below
@Component({ moduleId: module.id, selector: 'my-component', templateUrl: 'my-component.html', styleUrls: ['my-component.css'] }) export class MyComponent{ }
Can we load this dynamically into a container using its my-component selector
<div #container ></div> LoadComponent(selector: string){ // Load using selector? }
It may be necessary to export components to NgModule and import NgModule where we want to load it.
Not sure how to do this, any pointers in the right direction will be very helpful.
Thanks in advance!
source share