Angular – mat-error
Mat-error is a control tuned to display UI errors.
Here’s a sample
1 | <div mat-dialog-content> |
What I have learned, is that it will only fire if the control is considered an error. For that to happen the control needs to fail input validators. So I have code similar to the following:
In the declaration section of the .ts class
1 | policyTypeCodeForm = this.formBuilder.group ( { |
I think the form [formGroup] associates the form to the form builder group. The input tag, the formControlName=”code” is what binds the form field to the validators associated to that control (required, maxLength)
BTW, the save button starts like this
1 | public savePolicyTypeCode() { |
So I grab the values from the form, and put them into a PolicyTypeCode control.
References: