1

我想在日历中显示当前月份日期时禁用上个月日期和下个月日期。我可以做这个

HTML

 <div class='input-group date' id='datetimepicker1' ng-click="open1()">
      <input type="text" class="form-control" id="ReviewStartDate" name="ReviewStartDate" uib-datepicker-popup="{{format}}" ng-model="vm.product.ReviewStartDate" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />
      <span class="input-group-btn">
      <button type="button" class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button>
      </span>
 </div>

我可以禁用每周预期的日子,但我不能禁用上个月的日子和下个月的日子。我的预期输出只有当月的日子被启用,其他日子被禁用。

AngularJs 代码

 //================================DateTime Picker Start========================================================

    $scope.today = function () {
        $scope.dt = new Date();
    };
    $scope.today();

    $scope.clear = function () {
        $scope.dt = null;
    };

    $scope.inlineOptions = {
        //customClass: getDayClass,
        minDate: new Date(),
        showWeeks: true
    };

    $scope.dateOptions = {
        dateDisabled: disabled,
        formatYear: 'yy',
        maxDate: new Date(2050, 5, 22),
        minDate: new Date(),
        startingDay: 1
    };

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

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

    $scope.toggleMin();

    $scope.open1 = function () {
        $scope.popup1.opened = true;
    };
    $scope.open2 = function () {
        $scope.popup2.opened = true;
    };

    $scope.setDate = function (year, month, day) {
        $scope.dt = new Date(year, month, day);
    };

    //$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
    $scope.format = 'dd-MMMM-yyyy';
    $scope.altInputFormats = ['M!/d!/yyyy'];

    $scope.popup1 = {
        opened: false
    };
    $scope.popup2 = {
        opened: false
    };


    //================================DateTime Picker End========================================================

输出 在此处输入图像描述

我想喜欢这个 如何实现这个输出在此处输入图像描述

4

0 回答 0