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

Cannot read properties of undefined error when using array notation in expressionProperties #3264

Closed
andyault opened this issue Apr 8, 2022 · 1 comment
Labels

Comments

@andyault
Copy link

andyault commented Apr 8, 2022

Description
When trying to use an expressionProperty to update an array item, an error is thrown when using array syntax (array[i]), but not when using dot syntax (array.i).

Minimal Reproduction
https://stackblitz.com/edit/angular-q2hju2-evvvg2?file=src/app/app.component.ts

If line 26 in src/app/app.component.ts is uncommented, the console will show an error:

ERROR TypeError: [Formly Error] [Expression "templateOptions.options[1].label"] Cannot read properties of undefined (reading '1')
    at FieldExpressionExtension.setExprValue (angular-q2hju2-evvvg2.stackblitz.io/turbo_modules/@ngx-formly/core@5.12.0/bundles/ngx-formly-core.umd.js:3177:40)
    at FieldExpressionExtension.checkFieldExpressionChange (angular-q2hju2-evvvg2.stackblitz.io/turbo_modules/@ngx-formly/core@5.12.0/bundles/ngx-formly-core.umd.js:3021:30)
    at eval (angular-q2hju2-evvvg2.stackblitz.io/turbo_modules/@ngx-formly/core@5.12.0/bundles/ngx-formly-core.umd.js:2976:27)
    at Array.forEach (<anonymous>)
    at FieldExpressionExtension._checkField (angular-q2hju2-evvvg2.stackblitz.io/turbo_modules/@ngx-formly/core@5.12.0/bundles/ngx-formly-core.umd.js:2969:34)
    at FieldExpressionExtension.checkField (angular-q2hju2-evvvg2.stackblitz.io/turbo_modules/@ngx-formly/core@5.12.0/bundles/ngx-formly-core.umd.js:2932:41)
    at Object.eval [as _checkField] (angular-q2hju2-evvvg2.stackblitz.io/turbo_modules/@ngx-formly/core@5.12.0/bundles/ngx-formly-core.umd.js:2758:31)
    at FormlyFormBuilder.buildForm (angular-q2hju2-evvvg2.stackblitz.io/turbo_modules/@ngx-formly/core@5.12.0/bundles/ngx-formly-core.umd.js:828:31)
    at FormlyForm.ngOnChanges (angular-q2hju2-evvvg2.stackblitz.io/turbo_modules/@ngx-formly/core@5.12.0/bundles/ngx-formly-core.umd.js:1311:40)
    at checkAndUpdateDirectiveInline (angular-q2hju2-evvvg2.stackblitz.io/turbo_modules/@angular/core@7.2.16/bundles/core.umd.js:22116:23)

Your Environment

  • Angular version: 13.2.2
  • Formly version: 5.12.0

Additional context
Looks like this issue was previously reported (and fixed) here.

@andyault andyault added the bug label Apr 8, 2022
@andyault andyault changed the title Cannot read properties of undefined when using array notation in expressionProperties Cannot read properties of undefined error when using array notation in expressionProperties Apr 8, 2022
aitboudad added a commit to aitboudad/ngx-formly that referenced this issue Apr 22, 2022
aitboudad added a commit to aitboudad/ngx-formly that referenced this issue Apr 22, 2022
@aitboudad
Copy link
Member

This issue has been fixed and released as part of v5.12.1 release.

Please let us know, in case you are still encountering a similar issue/problem.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants