{"action":"created","issue":{"url":"https://api.github.com/repos/hartwig-at/fm-timepicker/issues/4","labels_url":"https://api.github.com/repos/hartwig-at/fm-timepicker/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/hartwig-at/fm-timepicker/issues/4/comments","events_url":"https://api.github.com/repos/hartwig-at/fm-timepicker/issues/4/events","html_url":"https://github.com/hartwig-at/fm-timepicker/issues/4","id":100097327,"number":4,"title":"Undefined dates cause control to error on load","user":{"login":"svantreeck","id":6819011,"avatar_url":"https://avatars.githubusercontent.com/u/6819011?v=3","gravatar_id":"","url":"https://api.github.com/users/svantreeck","html_url":"https://github.com/svantreeck","followers_url":"https://api.github.com/users/svantreeck/followers","following_url":"https://api.github.com/users/svantreeck/following{/other_user}","gists_url":"https://api.github.com/users/svantreeck/gists{/gist_id}","starred_url":"https://api.github.com/users/svantreeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svantreeck/subscriptions","organizations_url":"https://api.github.com/users/svantreeck/orgs","repos_url":"https://api.github.com/users/svantreeck/repos","events_url":"https://api.github.com/users/svantreeck/events{/privacy}","received_events_url":"https://api.github.com/users/svantreeck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-10T15:41:54Z","updated_at":"2015-08-10T18:28:03Z","closed_at":null,"body":"We end up binding the timepicker to a model that is fetched asynchronously, so at the time the control gets initialized, the time is undefined, and ensureTimeIsWithinBounds throws an error.  If I add `!time` to the initial check, it starts at 00:00 and the form loads without problem, which I think is OK (although it would be even better if it had no value).  The other workaround I have done is putting the time picker in a control that is excluded with ng-if when there is no value, but that's not ideal either.\r\n\r\n\t\t\t$scope.ensureTimeIsWithinBounds = function( time ) {\r\n\t\t\t\t// Constrain model value to be in given bounds.\r\n\t\t\t\tif(!time || time.isBefore( $scope.startTime ) ) {\r\n\t\t\t\t\treturn moment( $scope.startTime );\r\n\t\t\t\t}\r\n\t\t\t\tif( time.isAfter( $scope.endTime ) ) {\r\n\t\t\t\t\treturn moment( $scope.endTime );\r\n\t\t\t\t}\r\n\t\t\t\treturn time;\r\n\t\t\t};"},"comment":{"url":"https://api.github.com/repos/hartwig-at/fm-timepicker/issues/comments/129557595","html_url":"https://github.com/hartwig-at/fm-timepicker/issues/4#issuecomment-129557595","issue_url":"https://api.github.com/repos/hartwig-at/fm-timepicker/issues/4","id":129557595,"user":{"login":"oliversalzburg","id":1658949,"avatar_url":"https://avatars.githubusercontent.com/u/1658949?v=3","gravatar_id":"","url":"https://api.github.com/users/oliversalzburg","html_url":"https://github.com/oliversalzburg","followers_url":"https://api.github.com/users/oliversalzburg/followers","following_url":"https://api.github.com/users/oliversalzburg/following{/other_user}","gists_url":"https://api.github.com/users/oliversalzburg/gists{/gist_id}","starred_url":"https://api.github.com/users/oliversalzburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliversalzburg/subscriptions","organizations_url":"https://api.github.com/users/oliversalzburg/orgs","repos_url":"https://api.github.com/users/oliversalzburg/repos","events_url":"https://api.github.com/users/oliversalzburg/events{/privacy}","received_events_url":"https://api.github.com/users/oliversalzburg/received_events","type":"User","site_admin":false},"created_at":"2015-08-10T18:28:03Z","updated_at":"2015-08-10T18:28:03Z","body":"Please check 3.0.4 and see if that serves you any better :)"}}