1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to bind outputs to ng-template in Angular 20?

Discussão em 'Angular' iniciado por Konrad Viltersten, Julho 26, 2025.

  1. I'm doing the following, which works as expected.

    <ng-container
    *ngComponentOutlet="
    step.component | async;
    inputs: {
    someId: someId,
    stepper: stepper,
    step: step,
    model: model,
    };
    outputs: { decision: onDecision($event) }
    " />


    Since it works, I infer that I'm using correct imports, correct packages, syntax etc. Now, I need to establish communication in the other direction, so I simply added outputs as shown below.

    <ng-container
    *ngComponentOutlet="
    step.component | async;
    inputs: {
    someId: someId,
    stepper: stepper,
    step: step,
    model: model,
    };
    outputs: { decision: onDecision($event) }
    " />


    It sort-of works but gives an error suggesting that on the initial run, the component isn't ready yet so the outputs aren't recognized. I was surprised because the inputs seem to be, so I went to the docs for NgComponentOutlet and discovered that the outputs isn't documented there. There's no examples nor mentioning it at all.

    Where is that field documented and am I using something obsolete or magical at the moment?

    I sense that "it works but", because (aside of the above), I should get the error on not yet initialized component due to the async pipe. So I'm sensing that there's something wrong deeper than I see.

    https://angular.dev/api/common/NgComponentOutlet

    Continue reading...

Compartilhe esta Página