AngularJS minDate不工作

时间:2014-06-24 13:58:28

标签: javascript angularjs twitter-bootstrap

我将datepicker的minDate设置为今天,就像它在angularJS引导程序站点上设置一样,但是它无法正常工作。我没有得到任何控制台错误,但似乎minDat确实没有设置或其他东西。谢谢你的帮助!!

这里是js

angular.module('SelfExam.Quiz', [])
    .controller('QuizCtrl',['$scope','MeetingsService', function($scope, MeetingsService) {

        // DATEPICKER
        //Sets the default date, making adjustments for meetings that would otherwise land on a weekend date.
        $scope.date = new Date();
        $scope.date.setHours(0,0,0,0);
        if($scope.date.getDay() == 3 || $scope.date.getDay() == 4) {
            $scope.date.setDate($scope.date.getDate() + 5);
        } else {
            $scope.date.setDate($scope.date.getDate() + 3);
        }
        // Clears selection
        $scope.clear = function () {
            $scope.date = null;
        };

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

        };

        $scope.minDate = new Date();


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

            $scope.opened = true;
        };

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

        $scope.initDate = new Date('2016-15-20');
        $scope.formats = ["shortDate"];
        $scope.format = $scope.formats[0];
}]);

和HTML

...
<div class="col-md-6">
           <p class="input-group">
                   <input type="text" class="form-control" datepicker-popup="shortDate" id="date-field" ng-model="date" is-open="opened" min-date="minDate" max-date="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />
                           <span class="input-group-btn">
                           <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar" id="cal-button"></i></button>
               </span>
          </p>

  </div>
...

1 个答案:

答案 0 :(得分:1)

将html中的min-datemax-date更改为minmax