-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Closed
Copy link
Description
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
Yes
Description
Hello,
Working on a form with two template.
It seems that if we change template + setting form as disabled, the form is not disabling. But if we do it with separate thread via setTimeout, we have corrent working form disabling.
<ng-template #list>
<table class="list-table" cellspacing="0" cellpadding="0" [formGroup]="profileForm">
<tr>
<th>Named column</th>
</tr>
<tr>
<td style="vertical-align:bottom;">
<button mat-flat-button (click)="createButton()" ngDefaultControl formControlName="createButton">Create</button>
</td>
</tr>
</table>
</ng-template>
<ng-template #formList>
<p>This is formList..</p>
<table class="list-table" cellspacing="0" cellpadding="0" [formGroup]="profileFormFormed">
<tr>
<th>Named column</th>
</tr>
<tr>
<td style="vertical-align:bottom;">
<button mat-flat-button (click)="backButton()" ngDefaultControl formControlName="backButton">backButton</button>
</td>
</tr>
</table>
</ng-template>
<ng-container *ngTemplateOutlet="listOutlet ? list : (formListOutlet ? formList : null)"></ng-container>
private formBuilder = inject(FormBuilder);
profileForm: FormGroup = this.formBuilder.group({
createButton: new FormControl({ disabled: false, emitEvent: false, onlySelf: true })
});
profileFormFormed: FormGroup = this.formBuilder.group({
backButton: new FormControl({ disabled: true, emitEvent: false, onlySelf: true })
});
backButton() {
this.listOutlet = true;
this.formListOutlet = false;
// Отдельный поток позволяет блокировать форму после её показа.
// Если одновременно показать шаблон + блокировать форму, то форма не блокируется.
setTimeout(() => {
this.profileForm.disable(); // this work fine, but why??
}, 0);
}
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Just nothing happens, no errors.
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 20.0.1
Node: 22.16.0
Package Manager: npm 11.2.0
OS: win32 x64
Angular: 20.0.2
... cdk, common, compiler, compiler-cli, core, forms, material
... material-moment-adapter, platform-browser
... platform-browser-dynamic, router, service-worker
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.2000.1
@angular-devkit/build-angular 20.0.1
@angular-devkit/build-optimizer 0.1202.18
@angular-devkit/core 20.0.1
@angular-devkit/schematics 20.0.1
@angular/build 20.0.1
@angular/cli 20.0.1
@angular/localize 20.0.5
@schematics/angular 20.0.1
rxjs 7.8.2
typescript 5.8.3
zone.js 0.15.1
Anything else?
No response
Metadata
Metadata
Assignees
Labels
No labels