带有Valuechanges的DatePicker(材料设计(组件存在问题。当我们使用最小/最大输入时,会发生双重更改。因此,例如,我们接收到服务器的两个请求,而不是一个。
示例
使用 distinctUntilChanged
:
Stackblitz
this.form.valueChanges.pipe(
distinctUntilChanged(
(p, n) => p.fromDate === n.fromDate && p.toDate === n.toDate
)
).subscribe(value => {
this.count += 1;
console.log(value);
});