Issue
I just upgraded my app from Angular 8 to Angular 9. In this version (9), a class that use Angular features must have an appropriate Angular decorator. However, I have a component that is a @Component({...}). But where I run ng serve, it tells me that:
The class 'MyComponent' is listed in the declarations of the NgModule 'MyModule',
but is not a directive, a component, or a pipe.
Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.
I am looking for a way to tell Angular that my component is already a Angular component.
My module:
...
import { MyComponent } from './my-component/my-component.component';
...
@NgModule({
declarations: [
...,
MyComponent,
...
],
imports: [
CommonModule,
SharedModule,
MyModuleRoutingModule
],
providers: [...]
})
export class AnnuaireModule { }
My Component:
@Component({
selector: 'app-emmenagement-modale',
templateUrl: './emmenagement-modale.component.html'
})
export class EmmenagementModaleComponent implements OnInit {
...
}
Solution
It was the fact that ng update @angular/cli@^9 @angular/core@^9 let me with badly compilated modules. I delete node_modules and then npm i to have clean angular modules.
Answered By - Maxime Chevallier Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.