I am using a bootstrap datepicker. While sending the values from datepicker to server my format is mm/dd/yyyy For example: 06/24/2015
When I get the values back from the server ("06/24/2015"), I am trying to fill the datepicker input with 06/24/2015.
For this I am trying to do something like this:
$scope.startDate = ($scope.startDate == null) ? null : new Date($scope.startDate);
Now the $scope.startDate is Wed Jun 24 2015 00:00:00 GMT-0500 (Central Standard Time)
Then I am formatting it to display the date in the datepicker input like this:
$scope.startDate = $filter('date')($scope.startDate,'MM/dd/yyyy');
Now the value is 06/24/2015
Everything works fine but I see a script error saying:
TypeError: Cannot read property 'split' of undefined
at createParser (ui-bootstrap-tpls-0.11.0.min.js:8)
at parse (ui-bootstrap-tpls-0.11.0.min.js:8)
at m (ui-bootstrap-tpls-0.11.0.min.js:8)
at link.k.$render (ui-bootstrap-tpls-0.11.0.min.js:8)
at Object.<anonymous> (angular.js:23295)
at l.$digest (angular.js:14235)
at l.$apply (angular.js:14506)
at l (angular.js:9659)
at S (angular.js:9849)
at XMLHttpRequest.D.onload (angular.js:9790)
I searched a lot of questions and most of them say that this is a bug in datepicker and is available on github master and not yet released. I wanted to make sure the way I am parsing the dates is correct? Is there a better way to handle this problem and avoid getting the script error?