feat(angular): setting props on a signal works #29453
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue number: resolves #28876
What is the current behavior?
When assigning
componentProps
as inputs to an Angular component, we doObject.assign
. When using the newer Angular Signals API for inputs the value of an input is a function:The developer accesses the value of
myInput
in a template by doingmyInput()
sincemyInput
is a function.If a developer passes
componentProps: { myInput: 'bar' }
then the value ofmyInput
is set to this string value, overriding the function. As a result, callingmyInput()
results in an error becausemyInput
is a string not a function.What is the new behavior?
setInput
which lets us hand off setting inputs to Angular. This will set input values properly even when using a Signals-based input.Does this introduce a breaking change?
As part of this
NavParams
has been deprecated as it is incompatible with thesetInput
API. The oldObject.assign
worked to allow devs to get all of thecomponentProp
key value pairs viaNavParams
even if they are not defined asInputs
. UsingsetInput
will now throw an error, so developers need to create an@Input
for each parameter. This means thatNavParams
has no purpose and can safely be retired in favor of Angular's Input API. Not removing NavParms would make it difficult for us to support new Angular APIs such as this Signals-based input API.Other information
Dev build:
8.1.1-dev.11715021973.16675b67
You will need to update the Ionic config to opt-in to the new option: