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
I was updating an Angular 5.2 app to Angular 6.1 and run into similar issue. In this case the problem was that index.html file did not have at all. It was instead included in the
my-app
component.
Example
This used to work with Angular 5.2 (and earlier versions too) because in the generated index.html the script tags were placed at the end. After upgrade to 6.1 the script tags were instead placed in the beginning of the file (and I assume therefore executed before the
root element is actually present.
Solution was to move into index.html. (It was originally placed in to the component because someone wanted to apply conditional classes to body element with
ngClass
.)