I'm trying to build a simple tabs-menu in my Angular app.
parant.component.html:
<div>
<button (click)="selectTab(1)">Tab1</button>
<button (click)="selectTab(2)">Tab2</button>
<ng-container *ngTemplateOutlet="(selected == 1) ? template1 : template2">
</ng-container>
<ng-template #template1>I'm page 1</ng-template>
<ng-template #template2>I'm page 2</ng-template>
</div>
parant.component.ts:
public selected = 1;
public selectTab(tabName) {
this.selected = tabName;
}
This is working fine, as long as the <ng-template>
is part on the same page html. Now my pages (the content of #template1 and #template2) become complex and I want to move them to separate components.
How could I inject component into <ng-container>
??