date-max-limit =“”在720kb / angular-datepicker中不起作用?

时间:2018-02-14 12:41:15

标签: angularjs datepicker

我正在使用720kb / angular-datepicker。 date-max-limit无效。

我的控制器

$scope.currentDate = new Date().toString();

我的HTML colde

<datepicker date-format="yyyy-MM-dd">
<input type='text' class="titleInput date" id="lastmodifiedDate" name="lastmodifiedDate"
       date-max-limit="{{currentDate}}"
       ng-model="studyDetails.lastmodifiedDate" ng-blur="updateStudy('isForceSave')"/>

Github图书馆链接here

3 个答案:

答案 0 :(得分:2)

$scope.maxDate = new Date();
try this it will work.you pass wrong date format.you need to add date filter.then it will work
    date-max-limit="{{maxDate | date}}"

<div class="datepicker w-80 pull-right"
                    date-format="dd-MMMM-yyyy"               
                    date-max-limit="{{maxDate | date}}"
                    button-prev='<i class="fa fa-arrow-circle-left"></i>'
                    button-next='<i class="fa fa-arrow-circle-right"></i>'>                                                      
                   <input placeholder="Select DOB" readonly ng-model="users.dob" type="text"  class="searchbar3 w-100"  />

答案 1 :(得分:0)

您的日期并不尊重您的输入日期格式,因此请尝试将其替换为:

$scope.currentDate = new Date().toString();

用这个:

$scope.currentDate = new Date().toISOString().split('T')[0];

答案 2 :(得分:0)

您的html结构错误。将date-max-limit="{{currentDate}}"移至<datepicker>元素。见下文。

<datepicker date-format="yyyy-MM-dd" date-max-limit="{{currentDate}}" selector="form-control">
     <input ng-model="income.date" type="text" class="form-control"  required>
</datepicker>