Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError: Maximum call stack size exceeded #11205

Closed
sstriano opened this issue Aug 31, 2016 · 5 comments
Closed

RangeError: Maximum call stack size exceeded #11205

sstriano opened this issue Aug 31, 2016 · 5 comments

Comments

@sstriano
Copy link

RC5, Forms 0.3.0

Current behavior
Given the following form:

 this.form = this.formBuilder.group({
        merchantOrderId: this.return.merchantOrderId,
        agreeToReturnCharge: [true, Validators.required],
        returnChargeFeedback: [null],
        items: this.formBuilder.array(this.configureFormItems(this.return))
    });

`

When an item changes in the items FormArray:

let itemsArray = <FormArray>this.form.controls['items'];
this.subscriptions.push(itemsArray.valueChanges.subscribe(value => {
        let items: models.JetReturnItem[] = (<models.JetReturnItem[]>value);

        items.forEach((item: models.JetReturnItem, index: number) => {
            let control = itemsArray.controls[index];
            let refundFeedback = control.get('refundFeedback');

            refundFeedback.clearValidators();
            if (item.refundAmount.principal < item.requestedRefundAmount.principal) {
                refundFeedback.setValidators(Validators.required);
            }
            refundFeedback.updateValueAndValidity();
        });
    }));`

Calling the refundFeedback.updateValueAndValidity(); causes this error.

How do you add/remove validators and force validation to run with out this error?

  • Angular version: 2.0.0-rc.5
@vicb
Copy link
Contributor

vicb commented Aug 31, 2016

When creating an issue, please fill out the templates and provide a plunker.

We have too many incoming issue to afford spending time doing it.

@vicb vicb closed this as completed Aug 31, 2016
@sstriano
Copy link
Author

Could you please provide some examples of more advanced form usage in the documentation?

@zoechi
Copy link
Contributor

zoechi commented Sep 1, 2016

@sstriano documentation issues should be reported in https://github.com/angular/angular.io/issues

@martinpalmieri
Copy link

One thing you can try is to set the emitEvent on false for that formControl updateValueAndValidity method.

for example something like this:

refundFeedback.updateValueAndValidity({emitEvent : false});

from Angular docs:

If emitEvent is true, this change will cause a valueChanges event on the FormControl to be emitted. This defaults to true (as it falls through to updateValueAndValidity).

Also you have the possibility to onlySelf to false (is true by default) like this:

refundFeedback.updateValueAndValidity({onlySelf : true});

from Angular docs:

If onlySelf is true, this change will only affect the validation of this FormControl and not its parent component. This defaults to false.

I was having a similar problem with a tricky and big form. emitEvent saves me.

Hope it helps you.

Learn more about formControls here:

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants