I have a nested component in html side like following:
<main>
<ng-content *ngFor="let item in data">
<car *ngIf="item.type=='car'"></car>
<plane *ngIf="item.type=='car'"></plane>
</ng-content>
</main>
My car and plane components are implemented a base cehicle class.
export abstract class BaseVehicleComponent{
onVehicleCreated(){
console.log("on vehicle created.")
}
}
When a vehicle created, I want to populate an event in main component.
@Component({
selector: 'main',
})
export class MainComponent{
@Output() vehicleCreated = new EventEmitter<void>();
}
And hml updated like this:
<main (vehicleCreated)="onVehicleCreated($event)">
<ng-content *ngFor="let item in data">
<car *ngIf="item.type=='car'"></car>
<plane *ngIf="item.type=='car'"></plane>
</ng-content>
</main>
but base methot does not fire.
this.vehicleCreated.emit()?