I want to render a child component in a parent only when the child has finished an http call, but it doesn't work for me, the child component isn't displayed...
child selector in parent component
<app-child-component *ngIf="alert" (alert)="propagar($evento)"></app-child-component >
export class ParentComponent implements OnInit {
alert = false;
propagar(evento: boolean) {
this.alert = evento;
}
export class ChildComponent implements OnInit {
@Output alert = new EventEmitter<boolean>();
ngOnInit() {
this.childComponentService.getSomething().subscribe(response => {
if(this.response.code === 200)
this.alerta.emit(true);//here I just want the child component to be displayed
})
}
}
But it doesn't work, the child component is never shown even though the service responds correctly