filterForm = this.fb.group({
filterType: [''],
filterValue:['']
searchText:['']
});
this.filterForm.valueChanges.subscribe(res=>{
console.log(res); //some backend call
});
Я хочу применить несколько операторов rxjs, таких как debounce, DifferentUntilChanged, только к контроллеру формы searchText, чтобы я мог сделать вызов API, используя все значение формы.
Решение проблемы
Вы можете сделать это с помощью get для выбора элемента управления и канала перед подпиской:
filterForm = this.fb.group({
filterType: [''],
filterValue:['']
searchText:['']
});
this.filterForm.get('searchText').valueChanges.pipe(
distinctUntilChanged(),
debounce(500),
)
.subscribe(res=>{
console.log(res); //some backend call
});
Комментариев нет:
Отправить комментарий