问题描述
角 10
我正在尝试将 Angular Date Range 过滤器的 startDate 和 endDate 都设置回 null,但似乎在将 startDate 设置为 null 时,endDate 会自动注入上一个值。
下图中,this.selectedTimeFrame.startDate
和.endDate
一开始都是空的,但是运行this.filterGroup.get('startDate').setValue(null)
后,endDate不再是空了。
this.selectedTimeFrame = {
id: selectedTimeframe.id,startDate: selectedTimeframe.start(),endDate: selectedTimeframe.end()
};
this.fromradioBtn = true;
this.filterFormGroup.get('startDate').setValue(null);
this.filterFormGroup.get('startDate').setValue(this.selectedTimeFrame.startDate);
this.filterFormGroup.get('endDate').setValue(null);
this.filterFormGroup.get('endDate').setValue(this.selectedTimeFrame.endDate);
谁能解释一下?或者指出我是否做错了什么。
解决方法
我可能是错的,但请尝试使用 patchValue()
或 reset()
。