angular-ui/angular-ui-OLDREPO

date doesn't work if ng-model value is undefined

Closed this issue · 2 comments

A line like this:

<input ui-date ng-model="something.date" type="text"/>

will cause the following error if something = {} since something.date is undefined. Tested with Angular UI 0.4.0.

TypeError: Cannot call method 'getTime' of undefined
at Datepicker.setDate (http://localhost:9000/lib/datepicker/js/bootstrap-datepicker.js:276:31)
at HTMLInputElement.$.fn.datepicker (http://localhost:9000/lib/datepicker/js/bootstrap-datepicker.js:823:18)
at Function.b.extend.each (http://localhost:9000/lib/jquery/jquery.min.js:3:5257)
at b.fn.b.each (http://localhost:9000/lib/jquery/jquery.min.js:3:2013)
at $.fn.datepicker (http://localhost:9000/lib/datepicker/js/bootstrap-datepicker.js:815:15)
at link.controller.$render (http://localhost:9000/lib/angular-ui/angular-ui.js:299:21)
at Object.link.initDateWidget as fn
at Object.$get.Scope.$digest (http://localhost:9000/components/angular/angular.js:7878:27)
at Object.$get.Scope.$apply (http://localhost:9000/components/angular/angular.js:8079:24)
at done (http://localhost:9000/components/angular/angular.js:9089:20)

@brettatoms - Are you confusing your libraries? The ui-date directive is a wrapper around jQueryUI date picker not the bootstrap datepicker.

Turns out I was. Thanks.