Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): setting props on a signal works #28882

Closed
wants to merge 9 commits into from
Closed

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Jan 25, 2024

Issue number: resolves #28876


What is the current behavior?

When assigning componentProps as inputs to an Angular component, we do Object.assign. When using the newer Angular Signals API for inputs the value of an input is a function:

myInput = input<string>('foo') // this is a function

The developer accesses the value of myInput in a template by doing myInput() since myInput is a function.

If a developer passes componentProps: { myInput: 'bar' } then the value of myInput is set to this string value, overriding the function. As a result, calling myInput() results in an error because myInput is a string not a function.

What is the new behavior?

  • Angular 14.1 introduced 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?

  • Yes
  • No

As part of this NavParams has been removed as it is incompatible with the setInput API. The old Object.assign worked to allow devs to get all of the componentProp key value pairs via NavParams even if they are not defined as Inputs. Using setInput will now throw an error, so developers need to create an @Input for each parameter. This means that NavParams 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: 7.6.2-dev.11706205501.196a5433

@liamdebeasi liamdebeasi changed the title Fw 5923 fix(angular): setting props on a signal works Jan 25, 2024
@github-actions github-actions bot added the package: angular @ionic/angular package label Jan 25, 2024
@github-actions github-actions bot added package: core @ionic/core package and removed package: angular @ionic/angular package labels Jan 25, 2024
@liamdebeasi liamdebeasi changed the base branch from main to feature-8.0 January 25, 2024 17:05
@github-actions github-actions bot added package: angular @ionic/angular package and removed package: core @ionic/core package labels Jan 25, 2024
@thetaPC
Copy link
Contributor

thetaPC commented Jan 30, 2024

@liamdebeasi is this PR ready for review?

@liamdebeasi
Copy link
Contributor Author

Not yet. This requires a breaking change that I want to run by the team first.

@liamdebeasi
Copy link
Contributor Author

I'll close for now.

@liamdebeasi liamdebeasi reopened this Feb 15, 2024
@brandyscarney brandyscarney deleted the branch feature-8.0 April 17, 2024 19:27
@ntorrey
Copy link

ntorrey commented Apr 17, 2024

@brandyscarney Any hope Angular signals might be supported in future versions of Ionic?

@muuvmuuv
Copy link

The branch is merged into main recently and its name was 8.0, so I guess it will be in there? ^^

@brandyscarney
Copy link
Member

I did not close this PR. It was automatically closed when the feature-8.0 branch was deleted. Liam will have to open a new pull request to get this merged.

@EinfachHans
Copy link
Contributor

@brandyscarney does someone has this in their mind, now where liam left?

@thetaPC
Copy link
Contributor

thetaPC commented May 3, 2024

A new PR has been reopened! I recommend subscribing to it for more updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: angular @ionic/angular package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: componentProps of modalController does not work with Angular 17.1.0 signal inputs
6 participants