angularangular-routingangular-input

How to use angular's withComponentInputBinding for @Input and signal input/model to use their initial value if not set through router?


I feel like there is a happy median somewhere for the withComponentInputBinding option I am missing. Right now, I include it in providing my router in app.config, and any inputs I use that have initial values will be overriden with undefined when I render the component through router-outlet if I don't specify their values in any way through the route.

You'd think it'd be possible to configure it so that if an input isn't specified you just don't pass it in rather than passing undefined, but I'm not finding any way to do that. Is it even possible?

I've tried all versions of inputs for angular, including the signal input and model features, and all of their inputs are passed as undefined. If I remove withComponentInputBinding() then the initial values are used, so I have isolated it to that as the source of the issue.


Solution

  • The behavior your are observing is as designed.

    Failing to set the input to undefined would mean that it would retain the value from a previous navigation state.