@@ -336,6 +336,15 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
336
336
return this . _dropDownOverlaySettings || this . _defaultDropDownOverlaySettings ;
337
337
}
338
338
339
+ public get required ( ) : boolean {
340
+ if ( this . _ngControl && this . _ngControl . control && this . _ngControl . control . validator ) {
341
+ // Run the validation with empty object to check if required is enabled.
342
+ const error = this . _ngControl . control . validator ( { } as AbstractControl ) ;
343
+ // this.inputGroup.isRequired = error && error.required;
344
+ return error && error . required ;
345
+ }
346
+ }
347
+
339
348
public set dropDownOverlaySettings ( value : OverlaySettings ) {
340
349
this . _dropDownOverlaySettings = value ;
341
350
}
@@ -884,8 +893,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
884
893
if ( this . _ngControl ) {
885
894
this . _statusChanges$ = this . _ngControl . statusChanges . subscribe ( this . onStatusChanged . bind ( this ) ) ;
886
895
}
887
-
888
- this . manageRequiredAsterisk ( ) ;
889
896
}
890
897
891
898
protected onStatusChanged ( ) {
@@ -898,16 +905,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
898
905
input . valid = this . _ngControl . valid ? IgxInputState . INITIAL : IgxInputState . INVALID ;
899
906
}
900
907
}
901
- this . manageRequiredAsterisk ( ) ;
902
- }
903
-
904
- protected manageRequiredAsterisk ( ) : void {
905
- if ( this . _ngControl && this . _ngControl . control . validator ) {
906
- // Run the validation with empty object to check if required is enabled.
907
- const error = this . _ngControl . control . validator ( { } as AbstractControl ) ;
908
- this . inputGroup . isRequired = error && error . required ;
909
- this . _cdr . markForCheck ( ) ;
910
- }
911
908
}
912
909
913
910
/**
@@ -1332,7 +1329,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
1332
1329
return DatePickerUtil . addPromptCharsEditMode ( this . dateFormatParts , this . value , changedValue ) ;
1333
1330
}
1334
1331
1335
- private _updateValidity ( ) {
1332
+ public _updateValidity ( ) {
1336
1333
this . _onTouchedCallback ( ) ;
1337
1334
const input = this . readonlyInputDirective || this . editableInputDirective || this . input ;
1338
1335
if ( input && this . _ngControl && ! this . _ngControl . valid ) {
0 commit comments