@@ -73,10 +73,7 @@ picker.directive 'dateRangePicker', ($compile, $timeout, $parse, dateRangePicker
73
73
74
74
# Formatter should return just the string value of the input
75
75
# It is used for comparison of if we should re-render
76
- modelCtrl .$formatters .push (val) ->
77
- if val and val .startDate
78
- then _format (val)
79
- else ' '
76
+ modelCtrl .$formatters .push _format
80
77
81
78
# Render should update the date picker start/end dates as necessary
82
79
# It should also set the input element's val with $viewValue as we don't let the rangepicker do this
@@ -85,9 +82,8 @@ picker.directive 'dateRangePicker', ($compile, $timeout, $parse, dateRangePicker
85
82
if modelCtrl .$modelValue and modelCtrl .$modelValue .startDate
86
83
_setStartDate (modelCtrl .$modelValue .startDate )
87
84
_setEndDate (modelCtrl .$modelValue .endDate )
88
- else
89
- _clear ()
90
- # Update the input
85
+ else _clear ()
86
+ # Update the input with the $viewValue (generated from $formatters)
91
87
el .val (modelCtrl .$viewValue )
92
88
93
89
# This should parse the string input into an updated model object
@@ -109,7 +105,7 @@ picker.directive 'dateRangePicker', ($compile, $timeout, $parse, dateRangePicker
109
105
110
106
modelCtrl .$isEmpty = (val ) ->
111
107
# modelCtrl is empty if val is empty string
112
- not val and val .length > 0
108
+ not ( angular . isString ( val) and val .length > 0 )
113
109
114
110
# _init has to be called anytime we make changes to the date picker options
115
111
_init = ->
@@ -142,7 +138,7 @@ picker.directive 'dateRangePicker', ($compile, $timeout, $parse, dateRangePicker
142
138
_initBoundaryField = (field , validator , modelField , optName ) ->
143
139
if attrs[field]
144
140
modelCtrl .$validators [field] = (value ) ->
145
- validator (opts[optName], value[modelField])
141
+ value and validator (opts[optName], value[modelField])
146
142
$scope .$watch field, (date ) ->
147
143
opts[optName] = if date then moment (date) else false
148
144
_init ()
0 commit comments