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

Feature: Add Type To FormControl #20642

Closed
ewaschenko opened this issue Nov 27, 2017 · 3 comments
Closed

Feature: Add Type To FormControl #20642

ewaschenko opened this issue Nov 27, 2017 · 3 comments

Comments

@ewaschenko
Copy link

ewaschenko commented Nov 27, 2017

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[X] Feature request
[ ] Documentation issue or request
[ ] Support request

Current behavior

When creating a FormControl currently there is no way to specify the type within the FormControl or Group. (ie string, number, boolean, etc).

accountName: new FormControl("", []), This should be a string
'chequeNumber: new FormControl(0, []),' This should be a number, however it can change later to a string by a simple assignment.

The only way I know how to set the type is to set the HTML input type
<input matInput placeholder="Cheque Number" formControlName="chequeNumber" type="number" min="0" (blur)="formatNumber()" required>

Or use a class with the values and their types

export class Cheque{
      chequeNumber: number;
}

this.depositForm= this.fb.group({
  cheque: this.fb.group(new Cheque())
});

Expected behavior

It would be nice to be able to set the Types for each FormControl individually,

chequeNumber: new FormControl(number, 0, [])

Minimal reproduction of the problem with instructions

N/A

What is the motivation / use case for changing the behavior?

With specifying the type for a FormControl, the control will now know its type and offer it's associated functions, validation etc

Since Reactive Forms focus on explicit management, the type of each FormControl should be explicit as well and not rely on the initial value or the type specified in the HTML

Environment

N/A

Browser:
N/A

For Tooling issues:
N/A

Others:

@Toxicable
Copy link

duplicate of #13721

@kara
Copy link
Contributor

kara commented Nov 28, 2017

Looks related to #13721, so let's track it there.

@kara kara closed this as completed Nov 28, 2017
@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 Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants