Error if using AOT: "Cannot read property 'set' of undefined"
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Sorry, will will not be able to answer every support request. Please consider other venues for support requests
Current behavior This is my component code:
<div ngxDroppable="'page'" [model]="newForm.controls">
<div *ngFor="let control of newForm.controls; index as i; last as isLast" ngxDraggable="['page']" [model]="control">
<iqz-saf-form-section-edit [allControls]="newForm.controls" [section]="control" [totalSections]="newForm.controls.length" [currentSectionIndex]="i" (actionClicked)="handleSectionAction($event, i)"></iqz-saf-form-section-edit>
<div *ngIf="!isLast" class="field">
<div class="control">
<input class="is-checkradio is-small is-rtl" type="checkbox" id="{{'pagebreak_' + i}}" [value]="i" (change)="togglePagebreak(i)" [checked]="newForm.pageBreakIndices.indexOf(i) != -1" />
<label for="{{'pagebreak_' + i}}">Break to new page here</label>
</div>
</div>
</div>
</div>
The drag and drop feature works totally fine when using JIT compilation. However, if I compile via AOT, I get the following error in the browser console when visiting the page:
ERROR TypeError: Cannot read property 'set' of undefined
at DrakeStoreService.register (drake-store.service.js:24)
at DroppableDirective.ngOnInit (ngx-droppable.directive.js:50)
at checkAndUpdateDirectiveInline (core.js:12351)
at checkAndUpdateNodeInline (core.js:13878)
at checkAndUpdateNode (core.js:13821)
at debugCheckAndUpdateNode (core.js:14714)
at debugCheckDirectivesFn (core.js:14655)
at Object.eval [as updateDirectives] (new-intake-form.component.html:33)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:14640)
at checkAndUpdateView (core.js:13787)
Expected behavior AOT should work the same way as JIT.
Please tell us about your environment: Angular version: 5.2.0 Typescript version: 2.4.2
-
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] all
-
Language: [all | TypeScript X.X | ES6/7 | ES5] all
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
AOT: Error: Uncaught (in promise): TypeError: Cannot read ...
I am trying to publish an Angular4 front-end project in AOT production build. After long hours of getting angular cli to successfully build...
Read more >Ahead-of-time (AOT) compilation - Angular
Use the non-null type assertion operator to suppress the Object is possibly 'undefined' error when it is inconvenient to use *ngIf or when...
Read more >Popup throws the "Cannot read property 'show' of undefined ...
I have debugged AOT application using sourcemaps . I have that dxPopup is not loading. I am able reproduce in sample applications. Here...
Read more >ERROR in Cannot read property &#039;length&
Can you give more information about this: ERROR in Cannot read property 'length' of undefined ? Try to update "screenfull": "^3.3.0" to latest...
Read more >Angular 8 Webpack Aot Build Failed - Cannot Read Property ...
If you're using a library affected by this error, you should upgrade your @angular/cli version to 8 or disable optimization in production mode...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@rajshrimohanks Yes, we are currently using 3.1.0 and don’t see the issue.
@rdavidson
Can confirm that this doesn’t exist in v3.1.0. I’m temporarily rolling back to it. Thanks for the tip.