Can we load component dynamically in Angular 2 using it's selector?
Lets 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 it's selector my-component
<div #container ></div>
LoadComponent(selector: string){
// Load using selector?
}
There may be a need of exporting components in the NgModule and importing the NgModule where we want to load it.
Not sure on how to achieve this, any pointers in right direction would be very helpful.
Thanks in advance!!