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);
}
2
  • 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? Commented Sep 28, 2022 at 13:20
  • So trying to output console log to my DOM but with angular. As sample stackoverflow.com/questions/19846078/… I created Javascript web Editor and I have "output" element where I need to mirror console log with errors Commented Sep 28, 2022 at 14:23

1 Answer 1

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>

Sign up to request clarification or add additional context in comments.

1 Comment

The question is how to get a console from the browser and mirror to HTML as result\output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.