{"action":"created","issue":{"url":"https://api.github.com/repos/720kb/angular-datepicker/issues/65","labels_url":"https://api.github.com/repos/720kb/angular-datepicker/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/720kb/angular-datepicker/issues/65/comments","events_url":"https://api.github.com/repos/720kb/angular-datepicker/issues/65/events","html_url":"https://github.com/720kb/angular-datepicker/issues/65","id":86997450,"number":65,"title":"Datepicker type is typeof \"string\" after selecting a date.","user":{"login":"Krummelz","id":2780085,"avatar_url":"https://avatars.githubusercontent.com/u/2780085?v=3","gravatar_id":"","url":"https://api.github.com/users/Krummelz","html_url":"https://github.com/Krummelz","followers_url":"https://api.github.com/users/Krummelz/followers","following_url":"https://api.github.com/users/Krummelz/following{/other_user}","gists_url":"https://api.github.com/users/Krummelz/gists{/gist_id}","starred_url":"https://api.github.com/users/Krummelz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Krummelz/subscriptions","organizations_url":"https://api.github.com/users/Krummelz/orgs","repos_url":"https://api.github.com/users/Krummelz/repos","events_url":"https://api.github.com/users/Krummelz/events{/privacy}","received_events_url":"https://api.github.com/users/Krummelz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/720kb/angular-datepicker/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/720kb/angular-datepicker/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-10T14:55:31Z","updated_at":"2015-06-18T21:44:28Z","closed_at":null,"body":"I have the following html:\r\n\r\n    <datepicker>\r\n        <input type=\"text\" ng-model=\"Person.DateOfBirth\" />\r\n    </datepicker>\r\n\r\nAfter selecting the date, the DateOfBirth is a string, instead of a Date object. \r\nI checked `typeof Person.DateOfBirth` and it is indeed string"},"comment":{"url":"https://api.github.com/repos/720kb/angular-datepicker/issues/comments/113298030","html_url":"https://github.com/720kb/angular-datepicker/issues/65#issuecomment-113298030","issue_url":"https://api.github.com/repos/720kb/angular-datepicker/issues/65","id":113298030,"user":{"login":"WillBrindle","id":8310103,"avatar_url":"https://avatars.githubusercontent.com/u/8310103?v=3","gravatar_id":"","url":"https://api.github.com/users/WillBrindle","html_url":"https://github.com/WillBrindle","followers_url":"https://api.github.com/users/WillBrindle/followers","following_url":"https://api.github.com/users/WillBrindle/following{/other_user}","gists_url":"https://api.github.com/users/WillBrindle/gists{/gist_id}","starred_url":"https://api.github.com/users/WillBrindle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WillBrindle/subscriptions","organizations_url":"https://api.github.com/users/WillBrindle/orgs","repos_url":"https://api.github.com/users/WillBrindle/repos","events_url":"https://api.github.com/users/WillBrindle/events{/privacy}","received_events_url":"https://api.github.com/users/WillBrindle/received_events","type":"User","site_admin":false},"created_at":"2015-06-18T21:44:28Z","updated_at":"2015-06-18T21:44:28Z","body":"I needed this to return a date because I didn't want to have to keep parsing back to a date. For this I modified the code slightly. \r\n\r\nI added an extra binding ('dateModel': '=') which will now behave like ng-model. Whenever the date is changed that model will be updated. In the setInputValue I then as well as updating the input, I update $scope.model by using $scope.model in place of the local var modelDate.\r\n\r\nThe next issue after this was that the value would not display by default so I simply added in the link function:\r\n\r\n    if (attr.dateFormat && $scope.model) {\r\n\t\t\t$timeout(function() {\r\n\t\t\t\tthisInput.val($filter('date')($scope.model, dateFormat));\r\n\t\t\t\t $scope.month = $filter('date')($scope.model, 'MMMM');//December-November like\r\n            \t$scope.monthNumber = Number($filter('date')($scope.model, 'MM')); // 01-12 like\r\n            \t$scope.day = Number($filter('date')($scope.model, 'dd')); //01-31 like\r\n            \t$scope.year = Number($filter('date')($scope.model, 'yyyy'));//2014 like\r\n\t\t\t\t$scope.setDaysInMonth($scope.monthNumber, $scope.year);\r\n\t\t\t});\r\n        }\r\n\r\nThis can be improved to have a default dateFormat instead of just not displaying. The other parts of that extract also ensure that the datepicker is all set to the model value.\r\n\r\nFinally I added a change attribute ('change': '&') which I call in place of ensuring the change is called on the input.\r\n\r\nThis all probably has downsides to other uses of this but for my uses this works great. The changes are quite small and if anyone is interested I can fork this repo and put it up."}}