@@ -380,6 +380,15 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
380
380
return this . _dropDownOverlaySettings || this . _defaultDropDownOverlaySettings ;
381
381
}
382
382
383
+ public get required ( ) : boolean {
384
+ if ( this . _ngControl && this . _ngControl . control && this . _ngControl . control . validator ) {
385
+ // Run the validation with empty object to check if required is enabled.
386
+ const error = this . _ngControl . control . validator ( { } as AbstractControl ) ;
387
+ // this.inputGroup.isRequired = error && error.required;
388
+ return error && error . required ;
389
+ }
390
+ }
391
+
383
392
public set dropDownOverlaySettings ( value : OverlaySettings ) {
384
393
this . _dropDownOverlaySettings = value ;
385
394
}
@@ -934,8 +943,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
934
943
if ( this . _ngControl ) {
935
944
this . _statusChanges$ = this . _ngControl . statusChanges . subscribe ( this . onStatusChanged . bind ( this ) ) ;
936
945
}
937
-
938
- this . manageRequiredAsterisk ( ) ;
939
946
}
940
947
941
948
protected onStatusChanged ( ) {
@@ -948,16 +955,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
948
955
input . valid = this . _ngControl . valid ? IgxInputState . INITIAL : IgxInputState . INVALID ;
949
956
}
950
957
}
951
- this . manageRequiredAsterisk ( ) ;
952
- }
953
-
954
- protected manageRequiredAsterisk ( ) : void {
955
- if ( this . _ngControl && this . _ngControl . control . validator ) {
956
- // Run the validation with empty object to check if required is enabled.
957
- const error = this . _ngControl . control . validator ( { } as AbstractControl ) ;
958
- this . inputGroup . isRequired = error && error . required ;
959
- this . _cdr . markForCheck ( ) ;
960
- }
961
958
}
962
959
963
960
/**
@@ -1422,7 +1419,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
1422
1419
return DatePickerUtil . addPromptCharsEditMode ( this . dateFormatParts , this . value , changedValue ) ;
1423
1420
}
1424
1421
1425
- private _updateValidity ( ) {
1422
+ public _updateValidity ( ) {
1426
1423
this . _onTouchedCallback ( ) ;
1427
1424
const input = this . readonlyInputDirective || this . editableInputDirective || this . input ;
1428
1425
if ( input && this . _ngControl && ! this . _ngControl . valid ) {
0 commit comments