document.body.appendChild(elem) compiles but doesn't display anything

I’ve written some sample code such as this

var button = document.createElement('button');

    button.innerText = "Add";

    button.onclick = function () {};

    document.body.appendChild(button);

and

   var myImage: HTMLImageElement = new Image(100,100);
    myImage.src = '../../assets/images/black.png';
    document.body.appendChild(myImage);*/

and nothing shows up when I run the code. How do I fix this?

This is extremely unidiomatic for an Angular app. Managing the DOM is the framework’s job, not something the app code should be doing directly.

Hello,

addition what rapropos sad, is maybe your path wrong.

The path must be seen from index.html from your www folder. On a standard installion of your assets folder it should for an <img src='assets/…

Note, that you have by debugging in chrome two assets folders you can point to, but on device src/assets is not available.

Best regards, anna-liebt