为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

Smart猫小萌 2021-10-29 17:03:45
我只需要从多个最新订阅。当我的FormControl值发生变化时,我只需要在用户完成输入后获得最新值。这是我的代码 -let control = this.register.controls['email'];control.valueChanges.debounceTime(300).pipe(take(1)).subscribe(newValue => {  console.log(newValue);})但它返回多个Subscriptions. 我怎样才能得到最新的?
查看完整描述

2 回答

?
慕虎7371278

TA贡献1802条经验 获得超4个赞

您可以使用withlatestfrom


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

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

  console.log(newValue);

})

将此代码相应地更改为您的


查看完整回答
反对 回复 2021-10-29
  • 2 回答
  • 0 关注
  • 159 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信