将默认日期范围传递给 ng 引导日期范围选择器



我正在尝试将默认日期范围传递给 ng 引导日期范围选择器。输入字段不会更新。

ngOnInit() {
this.startDate = {year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate()};
this.maxDate = { year: now.getFullYear() + 1, month: now.getMonth() + 1, day: now.getDate()};
this.minDate = {year: now.getFullYear() - 1, month: now.getMonth() + 1, day: now.getDate()};
let parsed = ' '
this.fromDate = this.ngbCalendar.getToday();
this.toDate = this.ngbCalendar.getNext(this.ngbCalendar.getToday(), 'd', 10);
if(this.fromDate) {
parsed += this._parserFormatter.format(this.fromDate);
}
if(this.toDate) {
parsed += ' - ' + this._parserFormatter.format(this.toDate);
}
//passing default date
this.model = parsed;
this.renderer.setProperty(this.myRangeInput.nativeElement, 'value', parsed);
}

演示

从 html 中删除[(ngModel)]

相关内容

  • 没有找到相关文章

最新更新