diff --git a/src/datepickerPopup/popup.js b/src/datepickerPopup/popup.js index 3a6c9853a0..12ef4545a8 100644 --- a/src/datepickerPopup/popup.js +++ b/src/datepickerPopup/popup.js @@ -210,9 +210,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $ // Inner change $scope.dateSelection = function(dt) { - if (angular.isDefined(dt)) { - $scope.date = dt; - } + $scope.date = dt; var date = $scope.date ? dateParser.filter($scope.date, dateFormat) : null; // Setting to NULL is necessary for form validators to function $element.val(date); ngModel.$setViewValue(date); diff --git a/src/datepickerPopup/test/popup.spec.js b/src/datepickerPopup/test/popup.spec.js index b9d77c65c2..c26841c208 100644 --- a/src/datepickerPopup/test/popup.spec.js +++ b/src/datepickerPopup/test/popup.spec.js @@ -1041,6 +1041,13 @@ describe('datepicker popup', function() { expect($rootScope.date).toBe(null); }); + it('should clear the previously selected date', function() { + $rootScope.date = new Date(); + $rootScope.$digest(); + buttons.eq(1).click(); + expect($rootScope.date).toBe(null); + }); + it('should have a button to close calendar', function() { buttons.eq(2).click(); assignElements(wrapElement);