0

我正在運行最新的AngularUI Bootstrap,並且我有一個Datepicker,它在被按鈕打開時被啓用。AngularUI Bootstrap Datepicker設置最短日期

我已經試過並搜索瞭解如何禁用日期被點擊的答案,我希望2013年1月1日的最低日期 - 意思是2012年12月31日,而舊版本將不可選。

下面是我的代碼

ANGULARJS

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

        $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() { 
         $timeout(function() { 
          $scope.opened = true; 
          $scope.minEndDate = '2013-01-01'; 
         }); 
        }; 


        $scope.dateOptions = { 
         formatYear: 'yy', 
         startingDay: 1 
        }; 
        $scope.initDate = new Date('2016-15-20'); 
        $scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate']; 
        $scope.format = $scope.formats[0]; 

HTML

<input type="text" class="form-control input--text" datepicker-popup="{{format}}" ng-model="newperson.dob" is-open="$parent.opened" min="minEndDate" max-date="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" /> 
        <button type="button" class="datepicker-btn" ng-click="open()"><i class="fa fa-calendar"></i></button> 
+0

嘿唐納德,只是對我的舊回答進行清理,如果這恰好幫助你,請將此標記爲已回答。格拉西亞斯。 – acg 2014-09-23 13:46:04

回答

0

屬性是min-date你方纔min有:

<input type="text" class="form-control input--text" datepicker-popup="{{format}}" ng-model="newperson.dob" is-open="$parent.opened" min-date="minEndDate" max-date="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" /> 
        <button type="button" class="datepicker-btn" ng-click="open()"><i class="fa fa-calendar"></i></button> 
相關問題