繁体   English   中英

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

[英]date-max-limit="" is not working in 720kb/angular-datepicker?

我正在使用 720kb/angular-datepicker。 日期最大限制不起作用。

我的 controller

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

我的 HTML 冷

<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 图书馆链接在这里

您传递了错误的日期格式。无需转换为日期格式。只需像下面这样定义 & 在 date-max-limit 中以这种方式传递日期“{{maxDate | date}}”。您需要添加日期过滤器。它会工作肯定。

$scope.maxDate = 新日期();

<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"  />

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

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

有了这个:

$scope.currentDate = new Date().toISOString().split('T')[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>

当您将 date-min-limit 或 date-max-limit 添加到 datepicker 元素时,它肯定会起作用。 下面为我工作

$scope.minDate = new Date();

<datepicker date-format="MM/dd/yyyy" date-min-limit="{{minDate | date}}" class="date-picker">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM