Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

ElementRef in constructor is undefined after upgrading to 0.7.5 #602

Closed
nickwph opened this issue Jan 16, 2017 · 10 comments
Closed

ElementRef in constructor is undefined after upgrading to 0.7.5 #602

nickwph opened this issue Jan 16, 2017 · 10 comments

Comments

@nickwph
Copy link

nickwph commented Jan 16, 2017

After upgrading to zone.js 0.7.5, ElementRef of a component is no longer being injected.

constructor(private elementRef: ElementRef) {
    // elementRef is undefined
}
EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'nativeElement' of undefined
TypeError: Cannot read property 'nativeElement' of undefined
Unhandled Promise rejection: Cannot read property 'nativeElement' of undefined ; Zone: angular ; Task: Promise.then ; Value: TypeError: Cannot read property 'nativeElement' of undefined
    at RadioComponent.CheckboxComponent (http://localhost:3000/main.bundle.js:15686:42)
    at new RadioComponent (http://localhost:3000/main.bundle.js:19857:43)
    at new Wrapper_RadioComponent (/RadioModule/RadioComponent/wrapper.ngfactory.js:6:18)
    at CompiledTemplate.proxyViewClass.View_RadioDemoComponent0.createInternal (/RadioDemoModule/RadioDemoComponent/component.ngfactory.js:177:31)
    at CompiledTemplate.proxyViewClass.AppView.create (http://localhost:3000/vendor.bundle.js:12403:26)
    at CompiledTemplate.proxyViewClass.View_RadioDemoComponent_Host0.createInternal (/RadioDemoModule/RadioDemoComponent/host.ngfactory.js:15:19)
    at CompiledTemplate.proxyViewClass.AppView.createHostView (http://localhost:3000/vendor.bundle.js:12416:26)
    at ComponentFactory.create (http://localhost:3000/vendor.bundle.js:7840:30)
    at ViewContainerRef_.createComponent (http://localhost:3000/vendor.bundle.js:9699:67)
    at RouterOutlet.activate (http://localhost:3000/vendor.bundle.js:29593:43)
    at ActivateRoutes.placeComponentIntoOutlet (http://localhost:3000/vendor.bundle.js:28903:19)
    at ActivateRoutes.activateRoutes (http://localhost:3000/vendor.bundle.js:28870:29)
    at http://localhost:3000/vendor.bundle.js:28806:61
    at Array.forEach (native)
    at ActivateRoutes.activateChildRoutes (http://localhost:3000/vendor.bundle.js:28806:32) TypeError: Cannot read property 'nativeElement' of undefined
    at RadioComponent.CheckboxComponent (http://localhost:3000/main.bundle.js:15686:42)
    at new RadioComponent (http://localhost:3000/main.bundle.js:19857:43)
    at new Wrapper_RadioComponent (/RadioModule/RadioComponent/wrapper.ngfactory.js:6:18)
    at CompiledTemplate.proxyViewClass.View_RadioDemoComponent0.createInternal (/RadioDemoModule/RadioDemoComponent/component.ngfactory.js:177:31)
    at CompiledTemplate.proxyViewClass.AppView.create (http://localhost:3000/vendor.bundle.js:12403:26)
    at CompiledTemplate.proxyViewClass.View_RadioDemoComponent_Host0.createInternal (/RadioDemoModule/RadioDemoComponent/host.ngfactory.js:15:19)
    at CompiledTemplate.proxyViewClass.AppView.createHostView (http://localhost:3000/vendor.bundle.js:12416:26)
    at ComponentFactory.create (http://localhost:3000/vendor.bundle.js:7840:30)
    at ViewContainerRef_.createComponent (http://localhost:3000/vendor.bundle.js:9699:67)
    at RouterOutlet.activate (http://localhost:3000/vendor.bundle.js:29593:43)
    at ActivateRoutes.placeComponentIntoOutlet (http://localhost:3000/vendor.bundle.js:28903:19)
    at ActivateRoutes.activateRoutes (http://localhost:3000/vendor.bundle.js:28870:29)
    at http://localhost:3000/vendor.bundle.js:28806:61
    at Array.forEach (native)
    at ActivateRoutes.activateChildRoutes (http://localhost:3000/vendor.bundle.js:28806:32)
@JiaLiPassion
Copy link
Collaborator

@nickwph, can you provide a reproduce repo or plunker?

@nickwph
Copy link
Author

nickwph commented Jan 16, 2017

https://plnkr.co/edit/VjcSCz
There is a ZoneAwareError.

Unhandled Promise rejection: Cannot set property 'stack' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot set property 'stack' of undefined
    at SyntaxError.set [as stack] (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:1628:63)
    at assignAll (https://unpkg.com/zone.js@0.7.5/dist/zone.js:704:29)
    at SyntaxError.ZoneAwareError (https://unpkg.com/zone.js@0.7.5/dist/zone.js:775:16)
    at SyntaxError.BaseError [as constructor] (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:1590:18)
    at new SyntaxError (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:1793:18)
    at TemplateParser.parse (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:11210:21)
    at JitCompiler._compileTemplate (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:27480:70)
    at eval (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:27363:64)
    at Set.forEach (native)
    at JitCompiler._compileComponents (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:27363:21)
    at createResult (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:27246:21)
    at ZoneDelegate.invoke (https://unpkg.com/zone.js@0.7.5/dist/zone.js:242:26)
    at Zone.run (https://unpkg.com/zone.js@0.7.5/dist/zone.js:113:43)
    at https://unpkg.com/zone.js@0.7.5/dist/zone.js:535:57
    at ZoneDelegate.invokeTask (https://unpkg.com/zone.js@0.7.5/dist/zone.js:275:35) TypeError: Cannot set property 'stack' of undefined
    at SyntaxError.set [as stack] (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:1628:63)
    at assignAll (https://unpkg.com/zone.js@0.7.5/dist/zone.js:704:29)
    at SyntaxError.ZoneAwareError (https://unpkg.com/zone.js@0.7.5/dist/zone.js:775:16)
    at SyntaxError.BaseError [as constructor] (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:1590:18)
    at new SyntaxError (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:1793:18)
    at TemplateParser.parse (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:11210:21)
    at JitCompiler._compileTemplate (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:27480:70)
    at eval (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:27363:64)
    at Set.forEach (native)
    at JitCompiler._compileComponents (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:27363:21)
    at createResult (https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:27246:21)
    at ZoneDelegate.invoke (https://unpkg.com/zone.js@0.7.5/dist/zone.js:242:26)
    at Zone.run (https://unpkg.com/zone.js@0.7.5/dist/zone.js:113:43)
    at https://unpkg.com/zone.js@0.7.5/dist/zone.js:535:57
    at ZoneDelegate.invokeTask (https://unpkg.com/zone.js@0.7.5/dist/zone.js:275:35)

@JiaLiPassion
Copy link
Collaborator

@nickwph , Thank you for the plunker, I have made a new PR #597 to fix this issue.

@nickwph
Copy link
Author

nickwph commented Jan 16, 2017

Awesome! 😄

@JiaLiPassion
Copy link
Collaborator

0.7.6 has been released, please try it.

@ivaris
Copy link

ivaris commented Jan 19, 2017

Unhandled Promise rejection: Cannot set property 'stack' of undefined ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot set property 'stack' of undefined.

This happens when i use below to display html array of strings.

li *ngFor="#course of courses"
{{ course }}
/li

@JiaLiPassion
Copy link
Collaborator

@ivaris Could you provide a reproduce repo or plunker?

@ivaris
Copy link

ivaris commented Jan 19, 2017

@JiaLiPassion link for my code base. I just starting learning about angular2. i am working on mac https://github.com/ivaris/uiprojects/tree/development/myAngular2

@JiaLiPassion
Copy link
Collaborator

@ivaris , your repo don't have any src, and can't be download, could you check it again? Or maybe you can just zip your working copy (without node_modules) and paste here by dragging the file.

@JiaLiPassion
Copy link
Collaborator

close for not be able to reproduce.

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

3 participants