问题
I am trying out a very simple application on angular elements on stackblitz and I am getting the following issue.
Error: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
All I am trying to do is trying to display hello world. I didn't face any issue doing this on visual code locally, however, this issue comes up on stackblitz. Not sure I have to follow some additional steps on stackblitz in order for me to run this application. Appreciate any help on this.
Here is the link to the application on stackblitz.
回答1:
Downgrade document-register-element
to v1.8.1
solved it.
npm i document-register-element@1.8.1
Work for me.
Cr. https://github.com/angular/angular/issues/24390#issuecomment-396729418
回答2:
For anyone having this issue, just change the target
to es6
or es2015
in your tsconfig.json file. That will work perfectly.
来源:https://stackoverflow.com/questions/50553449/angular-elements-error-failed-to-construct-htmlelement