asterisk directive fix.
This commit is contained in:
parent
f27a98e488
commit
1cbb888ee1
|
@ -1,4 +1,4 @@
|
||||||
import { AfterContentChecked, Directive } from "@angular/core";
|
import { AfterContentChecked, Directive, Optional } from "@angular/core";
|
||||||
import { AbstractControl } from "@angular/forms";
|
import { AbstractControl } from "@angular/forms";
|
||||||
import { MatFormField } from "@angular/material/form-field";
|
import { MatFormField } from "@angular/material/form-field";
|
||||||
import { MatInput } from "@angular/material/input";
|
import { MatInput } from "@angular/material/input";
|
||||||
|
@ -15,9 +15,10 @@ import { MarkedValidatorFn } from "./validation/custom-validator";
|
||||||
})
|
})
|
||||||
export class ReactiveAsteriskDirective implements AfterContentChecked {
|
export class ReactiveAsteriskDirective implements AfterContentChecked {
|
||||||
private readonly requiredValidatornames = ['RequiredWithVisibilityRulesValidator', 'required'];
|
private readonly requiredValidatornames = ['RequiredWithVisibilityRulesValidator', 'required'];
|
||||||
constructor(private matFormField: MatFormField) { }
|
constructor(@Optional() private matFormField: MatFormField) { }
|
||||||
|
|
||||||
ngAfterContentChecked() {
|
ngAfterContentChecked() {
|
||||||
|
if (!this.matFormField) return;
|
||||||
const ctrl = this.matFormField._control;
|
const ctrl = this.matFormField._control;
|
||||||
const abstractControl = ctrl?.ngControl?.control;
|
const abstractControl = ctrl?.ngControl?.control;
|
||||||
const validators = (abstractControl as AbstractControl & { _rawValidators: MarkedValidatorFn[] })?._rawValidators;
|
const validators = (abstractControl as AbstractControl & { _rawValidators: MarkedValidatorFn[] })?._rawValidators;
|
||||||
|
|
Loading…
Reference in New Issue