且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

RangeError:使用 valueChanges.subscribe 时超出了最大调用堆栈大小

更新时间:2023-10-29 23:26:40

问题是你在 valueChanges 事件处理程序中为同一字段修改了字段的值,导致事件再次触发:

The problem is that you modify the value of the field inside of the valueChanges event handler for that same field, causing the event to be triggered again:

this.userForm.get('loginTypeId').valueChanges.subscribe(
  (loginTypeId: string) => {
    ...
    this.userForm.get('loginTypeId').updateValueAndValidity(); <-- Triggers valueChanges!
}