Angular input signal with function type

Discussão em 'Angular' iniciado por PaulBunion, Fevereiro 13, 2025.

  1. PaulBunion

    PaulBunion Guest

    I have an old @Input that passes a callback function from the parent component, which I'd like to convert to an input signal.

    Using the old decorator input, I can call the passed-in function simply by doing this.callback(). This of course doesn't work with an input signal because the same statement simply returns the input's value...which in this case is a function, so I would think this.callback()() would work to get the value of the input (the function) and then actually call the function, but it seems it does not.

    If I pass a function to an input signal (currently defined as callback = input.required<() => void>()), is there a way to actually call the function, or do I just need to stick with the old decorator input for now?

    Continue reading...

Compartilhe esta Página