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

Number inputs with a dynamic type always return strings #55002

Closed
jeffrey-thompson-fdx opened this issue Mar 22, 2024 · 2 comments
Closed

Number inputs with a dynamic type always return strings #55002

jeffrey-thompson-fdx opened this issue Mar 22, 2024 · 2 comments

Comments

@jeffrey-thompson-fdx
Copy link

jeffrey-thompson-fdx commented Mar 22, 2024

Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

No

Description

With a form control, if you have an <input type=number> with an attached formControl, when the input is changed from user interaction, the type of the value that's given is a number. However, if the input type is dynamically set (<input [type]="dynamicInputType" />), the value accessor that would normally apply doesn't apply, even if dynamicInputType is 'number', whether changed later or the initial value. This means that values returned from this control are strings instead of numbers.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-bf5qsf?file=src%2Fmain.ts

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 14.2.13
Node: 16.20.0
Package Manager: npm 8.19.4 
OS: linux x64

Angular: 14.3.0
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
... upgrade

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.13
@angular-devkit/build-angular   14.2.13
@angular-devkit/core            14.2.13
@angular-devkit/schematics      14.2.13
@angular/cdk                    14.2.7
@angular/cli                    14.2.13
@schematics/angular             14.2.13
rxjs                            7.8.1
typescript                      4.8.4
webpack                         5.81.0

This was replicated in Angular 17 using the stackblitz demo setup.

Anything else?

No response

@JoostK
Copy link
Member

JoostK commented Mar 22, 2024

This is a limitation of value accessors, which are determined statically. This is being tracked in #13243.

@JoostK JoostK closed this as not planned Won't fix, can't repro, duplicate, stale Mar 22, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants