【发布时间】:2020-05-14 05:22:54
【问题描述】:
trackFormChanges() {
this.form.valueChanges.pipe(
debounceTime(300),
distinctUntilChanged())
.subscribe(data => {
setTimeout(() => {
if (this.form.dirty && this.form.touched) { //dirty works but touched property has old value
this.prompt = true;
}
if (this.recordCopy) {
if (_.isEqual(this.record, this.recordCopy)) {
this.isSaved = true;
} else {
this.successes = [];
this.isSaved = false;
}
}
}, 500);
});
}
我正在尝试检查在触发 valueChanges 时表单是否被触摸,form.dirty 有效,但 form.touched 为假且不更新我不想订阅 form.statuschanges,以及更多高估更改多次触发。有什么办法可以处理吗?
【问题讨论】: