反应式表单值更改仅查看2个字段的方式[Angular2]

反应式表单值更改仅查看2个字段的方式[Angular2],angular,rxjs,Angular,Rxjs,我怎么能只看一个角反应形式的两个场呢? 我的表格如下: this.filter = this.fb.group({ text: ['', []], bankCountry: ['', []], bankCity: ['', []] }); 如何查看仅与最后两个字段相关的更改?两种方法: 首先,使用CombineTest: 第二,使用过滤器: 你可以使用rxjs.filter()操作符-类似于this.f

我怎么能只看一个角反应形式的两个场呢? 我的表格如下:

this.filter = this.fb.group({
            text: ['', []],
            bankCountry: ['', []],
            bankCity: ['', []]
        });
如何查看仅与最后两个字段相关的更改?

两种方法:

首先,使用CombineTest:

第二,使用过滤器:


你可以使用rxjs
.filter()
操作符-类似于
this.fb.changes.filter(…).subscribe()
我不明白这是怎么回事,你不能让谓词知道哪个值改变了或没有改变…关于谓词解决方案,你怎么知道哪个值改变了或没有改变,假设您不希望在值未更改时触发它?
Observable.combineLatest( this.text.valueChanges, this.bankCountry.valueChanges ).subscribe(respArr => {
     console.log(respArr); //this is array with responses from both observables
});
this.filter.valueChanges.filter((val) => /*filter predicate returning boolean*/).subscribe(val => {
    console.log(val);
});