angular - 可以在 Angular 的 NG-Bootstrap Datepicker 中选择相同的日期
问题描述
我正在使用使用 ng-bootstrap 日期选择器的日期范围日期选择器。但是我遇到了一个问题。我应该可以选择相同的日期。我将如何解决这个问题?请检查此链接 点击这里
onDateSelection(date: NgbDate) {
if (!this.fromDate && !this.toDate) {
this.fromDate = date;
} else if (this.fromDate && !this.toDate && date.after(this.fromDate)) {
this.toDate = date;
} else {
this.toDate = null;
this.fromDate = date;
}
}
解决方案
删除第三个验证器
else if
检查示例范围日期选择器
原来的
onDateSelection(date: NgbDate) {
if (!this.fromDate && !this.toDate) {
this.fromDate = date;
} else if (this.fromDate && !this.toDate && date.after(this.fromDate)) {
this.toDate = date;
} else {
this.toDate = null;
this.fromDate = date;
}
}
固定一个
onDateSelection(date: NgbDate) {
if (!this.fromDate && !this.toDate) {
this.fromDate = date;
} else if (this.fromDate && !this.toDate) {
this.toDate = date;
} else {
this.toDate = null;
this.fromDate = date;
}
}
推荐阅读
- javascript - 如何避免为 dataTables 中的每个按钮使用自定义脚本?
- rxjs - 可观察到的,它发出精确地按一定时间间隔分开的事件
- jwt - CAS JWT Service Ticket 文档中的“返回的断言长度”是什么意思?
- react-native - 显示 React Native 的 Flatlist 数组
- apollo - 使用 apollo-link-state 保存 @client 数据时出现“selectionSet 为空”错误
- r - 使用 Mtcars 示例在散点图中获得最佳拟合线
- getchar - Linux 上的 getchar() 可以读取哪些键盘字符
- javascript - 从动态路径中查找文件夹
- c# - 邻接矩阵中的 BFS
- wordpress - 移动库存管理器 Woocommerce API