Currently I'm using Angular 15 and in Angular 14 for the disabled input field in reactive form I used [attr.disabled]="disableField ? true : null"
.
This attribute after I update the Angular version 14 to 15 it's not working
Currently I'm using Angular 15 and in Angular 14 for the disabled input field in reactive form I used [attr.disabled]="disableField ? true : null"
.
This attribute after I update the Angular version 14 to 15 it's not working
It's a change in Angular 15 that changes the disabled state.
This behavior change was caused by a fix to make setDisabledState
always called. Previously, using [attr.disabled]
caused your view to be out of sync with your model.
If you are using Reactive Forms? Try setting disabled on your model, not your template. Try new FormControl({ value: 'foo', disabled: true })
. Or call myControl.disable()
in ngOnInit
.
If you want to opt-out of the fix. Make sure you're on 15.1.0 or later and import FormsModule.withConfig({ callSetDisabledState: 'whenDisabledForLegacyCode' })
(or ReactiveFormsModule
, if that's what you're using).
Please update your ReactiveFormsModule
import statement in your module file with below statement:
ReactiveFormsModule.withConfig({callSetDisabledState: 'whenDisabledForLegacyCode'})
© 2022 - 2025 — McMap. All rights reserved.