日期选择器验证不起作用

Datepicker validation not working

我在我的应用程序中的弹出窗口中添加了一个日期选择器,它工作正常,但是当我尝试提交表单时,我无法保存条目。我的表单验证器 returns false 即使有输入文本中的有效日期,但如果我更改日期,则表单验证器 returns true.. 这是我的代码

<p class="input-group">
                                            <input type="text" ng-click="open($event)" class="form-control registration-input"
                                                datepicker-popup="{{format}}"  show-button-bar="false" 
                                                ng-model="CompanyData.dateOfRegistration" name="dateOfRegistration"
                                                is-open="opened" datepicker-options="dateOptions" /> <span
                                                class="input-group-btn">
                                                <button type="button" class="btn btn-default"
                                                    ng-click="open($event)">
                                                    <i class="glyphicon glyphicon-calendar"></i>
                                                </button>
                                            </span>
                                        </p>

Below is the js code

// Disable weekend selection
    $scope.disabled = function(date, mode) {
      return ( mode === 'day' && ( date.getDay() === 0 || date.getDay() === 6 ) );
    };

  $scope.dates = [{date:'01-05-2001'}, {date:'05-05-2014'}, {date:'10-11-2008'}]
    $scope.open = function($event) {
      $event.preventDefault();
      $event.stopPropagation();

      $scope.opened = true;
    };

    $scope.dateOptions = {
      formatYear: 'yy',
      startingDay: 1,
      showWeeks:'false'
    };


    $scope.format = 'dd-MMMM-yyyy'

任何人都可以告诉我我应该做什么才能使这项工作..

My form validator returns false even though there is a valid date in the input text ?

因为 ngModel CompanyData.dateOfRegistration 最初没有设置,所以 undefined 是错误的。

即使日期选择器中有有效日期,但因为 ngModel 未初始化,所以它是 return false;

CompanyData.dateOfRegistration 设置为有效日期。