Skip to content

Commit

Permalink
fix(abc:se): fix missing required of reactive (#1737)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Dec 20, 2023
1 parent f374209 commit a2ca109
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/abc/se/se.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
inject
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControlName, NgModel, RequiredValidator, Validator } from '@angular/forms';
import { FormControlName, NgModel, RequiredValidator, Validator, Validators } from '@angular/forms';
import { filter } from 'rxjs';

import { ResponsiveService } from '@delon/theme';
Expand Down Expand Up @@ -181,8 +181,12 @@ export class SEComponent implements OnChanges, AfterContentInit, AfterViewInit {
}
// auto required
if (this.required !== true) {
const rawValidators = (this.ngControl as NzSafeAny)?._rawValidators as Validator[];
this.required = rawValidators.find(w => w instanceof RequiredValidator) != null;
let required = this.ngControl?.control?.hasValidator(Validators.required);
if (required !== true) {
const rawValidators = (this.ngControl as NzSafeAny)?._rawValidators as Validator[];
required = rawValidators.find(w => w instanceof RequiredValidator) != null;
}
this.required = required;
this.cdr.detectChanges();
}
}
Expand Down

0 comments on commit a2ca109

Please sign in to comment.