Cannot read property '_formBuilder' of undefined
draylegend opened this issue · comments
I'm submitting a...
[x] Bug report
Current behavior
I'm trying to save with forms manager the state of checkboxes in the table.
I have a list of users. When I click on a user, I then get a user's detail page (for simplicity some field are omitted). After changing the organisation ID in the mat-select, the customers appear with their rights in the table. After some change in the table, I then go back to the user's list and want to select the previous user in the list and then I get this error:
core.js:6014 ERROR Error: Uncaught (in promise): TypeError: Cannot read property '_formBuilder' of undefined
TypeError: Cannot read property '_formBuilder' of undefined
at _createCustomerWithRights (user-edit.component.ts:117)
at datorama-akita-ng-forms-manager.js:192
at Array.forEach (<anonymous>)
at datorama-akita-ng-forms-manager.js:192
at Array.forEach (<anonymous>)
at AkitaNgFormsManager.handleFormArray (datorama-akita-ng-forms-manager.js:183)
at AkitaNgFormsManager.resolveStoreToForm (datorama-akita-ng-forms-manager.js:171)
at AkitaNgFormsManager.upsert (datorama-akita-ng-forms-manager.js:94)
at UserEditComponent.<anonymous> (user-edit.component.ts:75)
at Generator.next (<anonymous>)
at resolvePromise (zone-evergreen.js:797)
at zone-evergreen.js:707
at fulfilled (tslib.es6.js:70)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:39699)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:39680)
Why is the this
undefined? Oo
I thought that this
is available right after the constructor was called.
Expected behavior
The forms manager should save the table's state (checked/unchecked checkboxes).
Minimal reproduction of the problem with instructions
Environment
Angular version: 8.2.13
Browser:
- [x] Chrome (desktop) version 78.0.3904.97 (Official Build) (64-bit)
For Tooling issues:
- Node version: 12.13.0
- Platform: Win 10 x64
Thank you in advance!
Best regards
Vladimir
I can't debug it if it works on stackblitz
You can clone the GitHub repo. There is the error described above. Sorry for the ambiguousness
You need to use bind
:
customersWithRights:this._createCustomerWithRights.bind(this)