1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Observing @Output Event Emitters in Child Components?

Discussão em 'Angular' iniciado por Ole, Outubro 15, 2024 às 18:33.

  1. Ole

    Ole Guest

    How should be go about using / observing parent @Output() event emitters in child components?

    For example in this demo the child component uses the @Output onGreetingChange like this:

    <app-greeting [greeting]="onGreetingChange | async"></app-greeting>


    And this will work if onGreetingChange emits in the AfterViewInit life cycle hook.

    ngAfterViewInit() {
    this.onGreetingChange.emit('Hola');
    }


    However that produces the an ExpressionChangedAfterItHasBeenCheckedError error.

    Is there a way to get to this to work without producing the error?

    I tried emitting in both the constructor and OnInit. Thoughts?

    Continue reading...

Compartilhe esta Página