@@ -13,6 +13,7 @@ import { services } from 'typescript-angular-utilities';
13
13
14
14
import __dateTimeFormatStrings = services . date ;
15
15
import __validation = services . validation ;
16
+ import __object = services . object ;
16
17
17
18
import {
18
19
IComponentValidator ,
@@ -81,9 +82,10 @@ export class DateTimeController {
81
82
}
82
83
}
83
84
84
- dateTime . $inject = [ services . moment . serviceName , __dateTimeFormatStrings . dateTimeFormatServiceName ] ;
85
+ dateTime . $inject = [ services . moment . serviceName , __dateTimeFormatStrings . dateTimeFormatServiceName , __object . serviceName ] ;
85
86
function dateTime ( moment : moment . MomentStatic
86
- , dateTimeFormatStrings : __dateTimeFormatStrings . IDateFormatStrings ) : angular . IDirective {
87
+ , dateTimeFormatStrings : __dateTimeFormatStrings . IDateFormatStrings
88
+ , object : __object . IObjectUtility ) : angular . IDirective {
87
89
'use strict' ;
88
90
return {
89
91
restrict : 'E' ,
@@ -117,9 +119,9 @@ function dateTime(moment: moment.MomentStatic
117
119
= dateTime . max != null ? dateTime . max : defaults . maxDate ;
118
120
119
121
scope . $watch ( ( ) : any => { return ngModel . $viewValue ; } , ( newValue : any ) : void => {
120
- if ( newValue !== '' ) {
121
- dateTime . validFormat = moment ( newValue ) . isValid ( ) ;
122
- }
122
+ dateTime . validFormat = object . isNullOrEmpty ( newValue )
123
+ ? true
124
+ : moment ( newValue ) . isValid ( ) ;
123
125
} ) ;
124
126
125
127
// --- Implementation ---
@@ -154,6 +156,6 @@ function dateTime(moment: moment.MomentStatic
154
156
} ;
155
157
}
156
158
157
- angular . module ( moduleName , [ services . moment . moduleName , services . date . moduleName , componentValidatorModuleName ] )
159
+ angular . module ( moduleName , [ services . moment . moduleName , services . date . moduleName , componentValidatorModuleName , __object . moduleName ] )
158
160
. directive ( directiveName , dateTime )
159
161
. controller ( controllerName , DateTimeController ) ;
0 commit comments