繁体   English   中英

尝试输入日期时得到“读取的属性的'长度'未定义”

[英]getting “read property 'length' of undefined” when try to enter date

你能告诉我为什么我会收到这个错误吗?

angular.js:12798 TypeError: Cannot read property 'length' of undefined
    at parseDateString (VM651 ui-bootstrap-tpls-2.5.0.js:3037)
    at Array.parseDate (VM651 ui-bootstrap-tpls-2.5.0.js:3062)
    at NgModelController.$$parseAndValidate (VM647 angular.js:25837)
    at NgModelController.$commitViewValue (VM647 angular.js:25827)
    at VM647 angular.js:25970
    at ChildScope.$eval (VM647 angular.js:16374)
    at ChildScope.$apply (VM647 angular.js:16474)
    at NgModelController.$$debounceViewValueCommit (VM647 angular.js:25969)
    at NgModelController.$setViewValue (VM647 angular.js:25941)
    at HTMLInputElement.listener (VM647 angular.js:22200)
(anonymous) @ angular.js:12798
(anonymous) @ angular.js:9545
$apply @ angular.js:16479
$$debounceViewValueCommit @ angular.js:25969
$setViewValue @ angular.js:25941
listener @ angular.js:22200
dispatch @ jquery.js:5183
elemData.handle @ jquery.js:4991

实际上,我尝试输入日期而不使用“ datepicker”,然后出现此错误,为什么.how解决此错误

重现此错误的步骤

  1. 运行应用程序。第一个日期字段为空。我仅在其中输入1 ,然后我会收到此错误的信息,为什么?

http://plnkr.co/edit/ZG4Inotn7EtVZ5QbCsMH?p=preview

$scope.changedate =function(){
    console.log('asda')
  }

我也没有改变事件。

我正在从这里https://angular-ui.github.io/bootstrap/#!#datepicker制作日期选择器

您已选择提供其他日期格式的集合,但尚未在HTML中正确映射它。

特别,

<input type="text" ng-change='changedate()' class="form-control" uib-datepicker-popup="{{format}}" ng-model="x.name" is-open="x.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="formats" />

您正在将alt-input-formats映射到altInputFormats (未定义)。

这是更新的Plunker。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM