簡體   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