Skip to content

Commit

Permalink
SNRGY-3650 fix ngControl error in chart widget edit dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
gr-st committed Dec 2, 2024
1 parent ba51ec1 commit 115b4ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/app/core/directives/matError.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ export class MatErrorMessagesDirective implements AfterViewInit, OnDestroy {
const container = this._inj.get(MatFormField);
this.inputRef = container._control;
if (this.formControl == null) {
this.formControl = this.inputRef.ngControl.control;
try {
this.formControl = this.inputRef.ngControl.control;
} catch (e) {
throw new Error('FormControl must be provided to mat-error with label: ' + this.label + '\n This ' +
'can be done by using formControlName, formControl, or ngModel in the relevant mat-form-field. ' +
'If there is no FormControl needed for the mat-form-field, then the mat-error is redundant, too.');
}
}

//console.log(this.label, ' inputRef: ', this.inputRef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ <h2>Configure Chart</h2>
<mat-form-field color="accent" appearance="outline" class="full-width">
<mat-label>X-Axis</mat-label>
<input type="text" matInput value="time" disabled>
<mat-error senergyError label="X-Axis"></mat-error>
</mat-form-field>
</td>
<td>
Expand Down

0 comments on commit 115b4ef

Please sign in to comment.