Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(datepicker): check if initDate is valid
Browse files Browse the repository at this point in the history
Closes #5190
Closes #5266
  • Loading branch information
AndriIushchuk authored and wesleycho committed Feb 24, 2016
1 parent 4bb178a commit ab59413
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,12 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
$log.warn('uib-datepicker initDate attribute usage is deprecated, use datepicker-options attribute instead');
}

this.activeDate = dateParser.fromTimezone($scope.$parent.$eval($attrs.initDate), ngModelOptions.timezone) || new Date();
var initDate = dateParser.fromTimezone($scope.$parent.$eval($attrs.initDate), ngModelOptions.timezone);
this.activeDate = !isNaN(initDate) ? initDate : new Date();
watchListeners.push($scope.$parent.$watch($attrs.initDate, function(initDate) {
if (initDate && (ngModelCtrl.$isEmpty(ngModelCtrl.$modelValue) || ngModelCtrl.$invalid)) {
self.activeDate = dateParser.fromTimezone(initDate, ngModelOptions.timezone);
initDate = dateParser.fromTimezone(initDate, ngModelOptions.timezone);
self.activeDate = !isNaN(initDate) ? initDate : new Date();
self.refreshView();
}
}));
Expand Down

0 comments on commit ab59413

Please sign in to comment.