What is the proper way to display components dynamically in a view?
As an example, I have a component which has a navigation and a view. Clicking a button in the navigation different sub-components should appear/disappear in the view. Each of the sub-components are of a different type.
import { Component, Input } from '@angular/core';
import { Controls } from './controls.service';
@Component({
selector: 'Controlpanel',
templateUrl: 'app/templates/controlPanel.component.html',
directives: Controls.directives()
})
export class ControlPanelComponent {
controls = Controls.objects;
activeControl:string = Controls.objects[0].name;
}
--
<nav class="container-fluid">
<div class="row">
<a *ngFor="let control of controls" (click)="toggleControl(control.name, $event)" role="button" href="#" class=" text-uppercase">
{{control.name}}
</a>
</div>
</nav>
<div>
<this is where i want the sub-component to appear/>
</div>