-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
Bug:
Given 2 components: App
and Sub
where App
has a reactive form containing
- a checkbox
Sub
component wrapped in a ngIf checking that the checkbox is checked- a submit button with
[disabled]="form.invalid"
and Sub
contains a required text input.
App.onInit
defines a FormGroup containing only the checkbox.
Sub.onInit
adds to the parent form a new FormGroup (parentFormDirective is injected with viewProvider)
All inputs have their matching material directives (e.g. mat-checkbox
, mat-button
, etc...")
When the checkbox is checked, ExpressionChangedAfterItHasBeenCheckedError
is thrown.
If mat-button
on the submit button is removed, the error is not thrown.
What is the expected behavior?
For ExpressionChangedAfterItHasBeenCheckedError
to not be thrown.
What is the current behavior?
ExpressionChangedAfterItHasBeenCheckedError
is thrown.
What are the steps to reproduce?
Sample project on github.
Created i StackBlitz, but got the following error when trying to save:
PATCH https://stackblitz.com/api/projects/angular-pc3way net::ERR_EMPTY_RESPONSE
What is the use-case or motivation for changing an existing behavior?
Nesting inside parent forms reusable components that impact form-validity, is one of the fundamental features of a component-based framework. Having a material-styled button should not break this feature.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular
5.2.8
Material
5.2.5
OS
Windows 10
TypeScript
2.4.2