why i got error NG6001 in angular 11 after editing the HTML template

1.5k views Asked by At

why i got the error in angular 11 --

NG6001: The class 'AppComponent' is listed in the declarations of the NgModule 'AppModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.

after i edit the Html template file ? if i add htnl entity there is no error but if i change entity for example from div to section - it is fail and give error NG6001 it is new project with only 1 component.no router.. and just the original module of the project. if i restart the ng server i don't get the error - so my code is ok... why i get the error?

1

There are 1 answers

0
yehonatan yehezkel On

after some more digging i find out it is issue in angular github repo. it will be fixed in angular 11.0.4

The issue here is that template parse errors result in the whole component being invalid, causing the NgModule declaration to also be flagged as invalid. This causes the implicit dependency from app.module.ts to app.component.html not to be registered, such that fixing the template does not invalidate the captured state for app.module.ts that still contains the error.

https://github.com/angular/angular/issues/39147