Angular 5:在输入中更改数据后运行函数

问题描述 投票:0回答:1

如何在时间1500之后检测输入和运行功能的变化.debounceTime不工作coreclty我的代码:

this.filterInput
    .valueChanges
    .debounceTime(1500) <- not working corectly
    .subscribe(text => {
        //function to run
    })

感谢帮助。

angular angular5
1个回答
0
投票

您可以在订阅中使用setTimeout

this.filterInput
    .valueChanges
    .subscribe(text => {
        setTimeout(
           ()=> {
              console.log("Executing after 1500ms");
           }, 1500
        )
    })
© www.soinside.com 2019 - 2024. All rights reserved.