如何将RXJS运算符应用于FormGroup中的单个FormControl
filterForm = this.fb.group({
filterType: [''],
filterValue:['']
searchText:['']
});
this.filterForm.valueChanges.subscribe(res=>{
console.log(res); //some backend call
});
我想将一些 rxjs 运算符(例如 debounce、distinctUntilChanged)应用于 searchText 表单控制器,以便我可以使用整个表单值进行 api 调用。
filterForm = this.fb.group({
filterType: [''],
filterValue:['']
searchText:['']
});
this.filterForm.valueChanges.subscribe(res=>{
console.log(res); //some backend call
});
I want to apply few rxjs operators like debounce, distinctUntilChanged only to searchText form controller so that I can make api call using the whole form value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过选择进行控制和管道在订阅之前:
You can do it with a get for select the control and a pipe before the subscribe:
我认为最简单的方法是只用要应用运算符的一个字段,然后用当前表单值替换其值:
I think the easiest way is piping only the one field where you want to apply the operators and then replace its value with the current form value: