我需要有一个重置按钮,但我的搜索,以及溃败。这就是我现在所拥有的。我相信我的问题是,我失去了‘这’的形式,一旦我重置。
searchForm = new FormControl('');
constructor(private searchService: SearchService){}
ngOnInit(): void {
this.searchForm.valueChanges.pipe(
debounceTime(500),
distinctUntilChanged())
.subscribe(() => {
this.getSearch();
});
}
getSearch(){
this.searchService.getSearch(this.searchForm.value).subscribe( res => console.log(res);
}
onReset(){
this.searchForm.reset();
}我的品牌打屁股的角度,我相信这是可怕的,我感谢帮助。
发布于 2020-05-27 19:06:07
将重置事件更改为:-
onReset(){
this.searchForm.reset(null, {emitEvent: false, onlySelf: true});
}这将防止向您的valueChanges发出此更改,并且不会对您的退欧时间产生影响。
https://stackoverflow.com/questions/62050895
复制相似问题