Angular2 - Error: The selector "app-root" did not match any elements

one of the simple way sometimes is just to create a new project (definitely only feasible if you are working on a basic project) - there are cases where you might have missed something - this way you can save some good time and focus on learning. This was my experience wasted almost 5 hours finding the reason why this didnt work and I was able to see output by just recreating the entire thing using basic start commands and code changes again on a new boilerplate.


Angular starts with a root component. When you give

bootstrap: [ AppComponent ]

in your app.modules.ts, angular searches for first instance of app-root in your HTML and replaces that tag with angular application. So, your AppComponent selector should match to the root component in HTML .

You need to add other component code inside app.component.html , so that angular can display them . It follows tree structure where app-root is at the top .

Tags:

Angular