Is it compulsory to pass {value, disabled} to FormControl
See original GitHub issueπ bug report
Affected Package
The issue is caused by package @angular/....Is this a regression?
Yes, the previous version in which this bug was not present was: .... No IdeaDescription
I am getting object object in input control but if i pass disabled key in FormControl then it works.
Expected: disabled key should be optional by default it will be false.
π¬ Minimal Reproduction
Stackblitz: https://stackblitz.com/edit/angular-uxlh5z?file=src%2Fapp%2Fapp.component.ts
code:
this.myForm = new FormGroup(
{
test: new FormControl({ value: "Husky" }, [
Validators.required
])
},
// this will work if i pass disabled key
/* {
test: new FormControl({ value: "Husky", disabled: true }, [
Validators.required
])
}, */
{ updateOn: "blur" }
);
π₯ Exception or Error
π Your Environment
Angular Version:
"@angular/common": "^8.0.0",
"@angular/compiler": "^8.0.0",
"@angular/core": "^8.0.0",
"@angular/forms": "^8.0.0",
"@angular/platform-browser": "^8.0.0",
"@angular/platform-browser-dynamic": "^8.0.0",
"@angular/router": "^8.0.0",
"core-js": "2",
"rxjs": "^6.5.2",
"zone.js": "^0.9.1"
Anything else relevant?
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Disable Input fields in reactive form - angular - Stack Overflow
I tried to do the following: form = new FormGroup({ first: new FormControl({value: '', disabled: true}, Validators. required), }); not working!
Read more >Exploring the difference between disabling a form control ...
We've given the form controls default values, disabled both the controls and required the firstName control by having a required validator on its...
Read more >Disable Angular FormControl - ConcretePage.com
We can disable a FormControl by passing disabled attribute while instantiating it. We can use disable() and enable() method of FormControl.
Read more >Disabling Form Controls When Working With Reactive Forms ...
Instantiate a new FormControl with the disabled property set to true. FormControl({value: '', disabled: true}) . Calling control.disable() or control.enable() .
Read more >aria-disabled - Accessibility - MDN Web Docs
If you are purposefully using the aria-disabled attribute to allow for a form control to remain in the page's keyboard focus order, particularlyΒ ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @indraraj26, thanks for the reply. I think changing this logic might be tricky and will result in a breaking change. We should probably start with the documentation update and revisit this in the future (to see if there is a better way to package value and disabled state). Thank you.
@indraraj26 You Can directly assign the value like this also as a string this.myForm = new FormGroup( { test: new FormControl(βHuskyβ, [ Validators.required ]) },