Inazuma
Inazuma

Reputation: 1

Angular console.log output to html

I created a web js editor with angular and ngx-ace-wrapper lib. Now I trying to output a console.log to HTML div element. But I do not found any solution. How I can get console output or mirror to my DOM.

I tried to override conmsole.log and console.error

"preview" is a variable where I store my output as innerHTML

console.log = message => {
  this.preview += message + "\n";

    _log(message);

}
console.error = error => {
  this.preview += JSON.stringify(error) + "\n";
  _error(error);
}

Upvotes: 0

Views: 863

Answers (1)

Donald Duck
Donald Duck

Reputation: 638

To get the HTML to render you can save the HTML in some variable and use the innerHtml attribute and pass in your html

<div [innerHTML]="myHtml"></div>

Upvotes: 0

Related Questions