table: tsconfig target es6 causes `_elementRef` failure during table creation
See original GitHub issueBug, feature request, or proposal:
Seems like all of my uses of <mat-table>
and <table mat-table>
broke with an undefined elementRef
after upgrading from 6.1.x to 7.0.0 using ng update
.
What is the expected behavior?
Tables should render and not throw an error on start.
What is the current behavior?
I receive the following error.
core.js:15043 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'nativeElement' of undefined
TypeError: Cannot read property 'nativeElement' of undefined
at new CdkTable (table.js:1071)
at new MatTable (table.js:28)
at createClass (core.js:23001)
at createDirectiveInstance (core.js:22828)
at createViewNodes (core.js:24376)
at callViewAction (core.js:24825)
at execComponentViewsAction (core.js:24731)
at createViewNodes (core.js:24405)
at callViewAction (core.js:24825)
at execComponentViewsAction (core.js:24731)
at new CdkTable (table.js:1071)
at new MatTable (table.js:28)
at createClass (core.js:23001)
at createDirectiveInstance (core.js:22828)
at createViewNodes (core.js:24376)
at callViewAction (core.js:24825)
at execComponentViewsAction (core.js:24731)
at createViewNodes (core.js:24405)
at callViewAction (core.js:24825)
at execComponentViewsAction (core.js:24731)
at resolvePromise (zone.js:814)
at resolvePromise (zone.js:771)
at zone.js:873
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:16954)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
at drainMicroTaskQueue (zone.js:595)
_elementRef
is undefined for some reason.
What are the steps to reproduce?
Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV
Setup any type of mat-table and the cdk table constructor doesn’t get it’s element ref injected.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
7.0.0 w/ angular 7.0.0 on chrome 70.0.3538.67 (Official Build) (64-bit)
Is there anything else we should know?
Seems to be working on the docs. Wondering if it’s just with upgraded apps? Going to check if a new gen app works with table.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
48 answers on StackOverflow to the most popular Angular ...
Specifically, we must unsubscribe before Angular destroys the component. Failure to do so could create a memory leak. We unsubscribe from our ...
Read more >Changing the target version of TypeScript Code causes the ...
The module option has a different default based on target and the moduleResolution option ... This is what lead to the change in...
Read more >Read Introduction to Angular 2 | Leanpub
In Object-oriented programming, a class can inherit from another class which helps to define shared attributes and methods among objects. Although this pattern ......
Read more >React TypeScript CheatSheet - Breword 文档集合
Basic Cheatsheet Table of Contents ... Next.js: npx create-next-app -e with-typescript will create in your current folder ... Option 1: DOM element ref....
Read more >Creating a Development Environment for Custom Visualizations
Basically, Looker wants you to provide a reference to your single js file in the admin page so it has the ability to...
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 FreeTop 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
Top GitHub Comments
@GeorgeTailor I had the same _elementRef issue and was able to find a fix for it on these forums. I verified it today using Angular 7.2.9 with Material 2 7.3.5. I target es6 and my tables work by using “ng serve --aot” in the scripts section in package.json. Without the –aot the tables still do not work and I get the same _elementRef error.
The original solution can be found at: MatTable: Cannot read property ‘nativeElement’ of undefined #9813
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.