I want to pass html element from parent to child based on conditions like If user click button in parent child should display button or If user select chckbox then child should display checkbox This is my scenario
To solve this I am using ngTemplateOutlet, ngContent through content projection concepts in angular.
I am getting error in console ERROR Error: templateRef.createEmbeddedView is not a function
I tried like this
<button (click)="getType('button')">Display button in child</button>
<div>
<label>checkbox</label>
<input type="checkbox" (change)="getType('checkbox')">
</div>
<app-child>
<ng-container [ngTemplateOutlet]="dynamicElement"></ng-container>
<ng-template #tp2>
<button>Hey I am button passed dynamically from parent</button>
</ng-template>
<ng-template #tp3>
<label>I am checkbox passed from parent</label>
<input type="checkbox" (change)="getType('checkbox')">
</ng-template>
Please find link I work out https://stackblitz.com/edit/angular-yzzsgs-dnfgaq?file=src/app/app.component.ts
Is there any other way?
Any help will appreciable
Thanks in advance