0

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);
}
Inazuma
  • 1
  • 1
  • why would you want to do that? This seems like a major red flag to me. Can you provide some more information on why you are trying to achieve this? – Fabian Strathaus Sep 28 '22 at 13:20
  • So trying to output console log to my DOM but with angular. As sample https://stackoverflow.com/questions/19846078/how-to-read-from-chromes-console-in-javascript I created Javascript web Editor and I have "output" element where I need to mirror console log with errors – Inazuma Sep 28 '22 at 14:23

1 Answers1

0

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>

Donald Duck
  • 618
  • 2
  • 6