From 115b4ef16e52e71db35f4dc730e7490ede4b618e Mon Sep 17 00:00:00 2001 From: Greta Date: Mon, 2 Dec 2024 15:03:40 +0000 Subject: [PATCH] SNRGY-3650 fix ngControl error in chart widget edit dialog --- src/app/core/directives/matError.directive.ts | 8 +++++++- .../dialog/charts-export-edit-dialog.component.html | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/core/directives/matError.directive.ts b/src/app/core/directives/matError.directive.ts index 57e38adc..aad79615 100644 --- a/src/app/core/directives/matError.directive.ts +++ b/src/app/core/directives/matError.directive.ts @@ -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); diff --git a/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.html b/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.html index a1967814..022ed8f2 100644 --- a/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.html +++ b/src/app/widgets/charts/export/dialog/charts-export-edit-dialog.component.html @@ -75,7 +75,6 @@

Configure Chart

X-Axis -