Angular - 从多个订阅中获取一个订阅

我只需要从多个最新订阅。


当我的FormControl值发生变化时,我只需要在用户完成输入后获得最新值。这是我的代码 -


let control = this.register.controls['email'];

control.valueChanges.debounceTime(300).pipe(take(1)).subscribe(newValue => {

  console.log(newValue);

})

但它返回多个Subscriptions. 我怎样才能得到最新的?


Smart猫小萌
浏览 160回答 2
2回答

慕虎7371278

您可以使用withlatestfromlet control = this.register.controls['email'];control.valueChanges.debounceTime(300).pipe(withLastestForm(control.valueChanges)).subscribe(newValue => {  console.log(newValue);})将此代码相应地更改为您的
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript