首页 > 解决方案 > angularjs - ui-bootstrap-tpls-0 datepicker-popup 无法手动输入

问题描述

我正在使用ui-bootstrap-tpls-0.12.0.js版本。当我通过日历选项(格式 yyyy/MM/dd)选择日期时,它的工作正常。但是,如果我在具有相同格式的输入文本中手动输入日期yyyy/MM/dd并单击保存按钮。日期值从输入文本框中消失。

请在下面找到我的代码。

<p class="input-group" ng-controller="DatePickerController">
    <span class="input-group-btn">
        <button type="button" class="btn btn-default" ng-click="open($event)" disabled >
            <i class="glyphicon glyphicon-calendar"></i>
        </button>
    </span>
    <input  type="text" class="form-control" ng-model="ban.effectiveDate" ng-readonly="true" datepicker-popup="yyyy/MM/dd" is-open="opened" ng-required="true" tabindex = "-1" close-text="Close"/>
</p>

我的控制器:

angular.module('app').controller('DatePickerController', ["$scope",function ($scope) {
      $scope.today = function() {
        $scope.dt = new Date();
      };

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

      $scope.toggleMin = function() {
        $scope.minDate = $scope.minDate ? null : new Date();
      };
      $scope.toggleMin();

      $scope.open = function($event) {
        $event.preventDefault();
        $event.stopPropagation();

        $scope.opened = true;
      };

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

      $scope.today();
      $scope.format = 'yyyy/MM/dd';
}]);

在此处输入图像描述

标签: javascriptangularjsdatepicker

解决方案


推荐阅读