Angular ngb datepicler中更改事件的更改日期
我有这个范围选择弹出从ngb日期选择器。 我从后端得到了初始日期,一切正常。但是当我更新日期时,它在输入字段中没有改变。如何修复此错误Angular ngb datepicler中更改事件的更改日期,angular,ng-bootstrap,ngb-datepicker,Angular,Ng Bootstrap,Ngb Datepicker,我有这个范围选择弹出从ngb日期选择器。 我从后端得到了初始日期,一切正常。但是当我更新日期时,它在输入字段中没有改变。如何修复此错误 我添加了TS文件,这与给定的exmaple相同。但我认为TS文件没有问题 onDateSelection(date: NgbDate) { if (!this.fromDate && !this.toDate) { this.fromDate = date; } else if (this.fromDate &
我添加了TS文件,这与给定的exmaple相同。但我认为TS文件没有问题
onDateSelection(date: NgbDate) {
if (!this.fromDate && !this.toDate) {
this.fromDate = date;
} else if (this.fromDate && !this.toDate && date && date.after(this.fromDate)) {
this.toDate = date;
} else {
this.toDate = null;
this.fromDate = date;
}
}
isHovered(date: NgbDate) {
return this.fromDate && !this.toDate && this.hoveredDate && date.after(this.fromDate) && date.before(this.hoveredDate);
}
isInside(date: NgbDate) {
return this.toDate && date.after(this.fromDate) && date.before(this.toDate);
}
isRange(date: NgbDate) {
return date.equals(this.fromDate) || (this.toDate && date.equals(this.toDate)) || this.isInside(date) || this.isHovered(date);
}
validateInput(currentValue: NgbDate | null, input: string): NgbDate | null {
const parsed = this.formatter.parse(input);
return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue;
}
下一步
(值)
代替[(ngModel)]
[ngModelOptions]=“{updateOn:'blur'}”
请共享ts文件code@DeepuReghunath我已添加ts文件,请帮助。什么是
splitRuleDetail
?无法在ts文件中找到
onDateSelection(date: NgbDate) {
if (!this.fromDate && !this.toDate) {
this.fromDate = date;
} else if (this.fromDate && !this.toDate && date && date.after(this.fromDate)) {
this.toDate = date;
this.sub.close(); // close manually
} else {
this.toDate = null;
this.fromDate = date;
}
}
isHovered(date: NgbDate) {
return this.fromDate && !this.toDate && this.hoveredDate && date.after(this.fromDate) && date.before(this.hoveredDate);
}
isInside(date: NgbDate) {
return this.toDate && date.after(this.fromDate) && date.before(this.toDate);
}
isRange(date: NgbDate) {
return date.equals(this.fromDate) || (this.toDate && date.equals(this.toDate)) || this.isInside(date) || this.isHovered(date);
}
validateInput(currentValue: NgbDate | null, input: string): NgbDate | null {
const parsed = this.formatter.parse(input);
return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue;
}