Artin Zareie
Artin Zareie

Reputation: 159

Error "String contains an invalid character" in angular 6 application

I have made an 7 angular application. and I use firefox nightly to run this application.

But when I run the application with ng serve -o I get an error:

ERROR DOMException: "String contains an invalid character" AppComponent.html:1
ERROR CONTEXT 
Object { view: {…}, nodeIndex: 1, nodeDef: {…}, elDef: {…}, elView: {…} }
DOMException: "String contains an invalid character"
<!-- app.component.html -->
<app-header></app-header>
<router-outlet></router-outlet>
<app-footer></app-footer>

// router
[
    {path: '', component: HomeComponent}
]

This error just appear on firefox nightly and firefox for developers

Upvotes: 1

Views: 3044

Answers (1)

David Renner
David Renner

Reputation: 484

Just had a similar error - It is not easy to track down just having this error message.

In general: First try to localize the lines failing for instance by temporarely deleting random parts of HTML of Component in question and find the culprit - when this is done you can ask or already have a clue how to fix.

In my case: I just copy & pasted code from TS to HTML-File with semicolon inside like:

<app-sequence-live
  (voteDoOverride)="voteDoOverride($event)";
></app-sequence-live>

Fixed:

<app-sequence-live
  (voteDoOverride)="voteDoOverride($event)"
></app-sequence-live>

Upvotes: 2

Related Questions