The problem is when I run my app, it works fine. But when I refresh it, most of the time I get below msg.
The selector \"my-app\" did not match any e
This happened to me because I was importing my code in the head tag, so it was potentially running and attempting to bootstrap before the DOM was ready.
You can either move the script to the bottom of the body tag, or put the bootstrap code within an event listener:
document.addEventListener("DOMContentLoaded", function(event) {
bootstrap(AppComponent);
});
or:
Example app