【发布时间】:2019-05-03 07:51:03
【问题描述】:
我有表格:
this.filterForm = this.fb.group({
type: [null, [Validators.required]]});
我听变化:
this.filterForm.controls["type"].valueChanges.subscribe(
selectedValue => {
});
在上面的代码中,我得到了元素的selectedValue,如何获取以前的值进行比较:
if (old("type") !== selectedValue) {
// Call user method
}
我尝试使用表单中的其他两个字段来执行此操作:
Observable.merge(this.filterForm.controls["classNumber"].valueChanges, this.filterForm.controls["classSuffix"].valueChanges).subscribe(response => {
if (response[0] !== this.filterForm.value.classNumber && this.filterForm.controls["classSuffix"]) { // Call method }
});
【问题讨论】:
-
复选框值?
-
不,选择列表
标签: angular angular-reactive-forms