PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 14, 2022

[FIXED] How to prove Angular that a class is Angular decored?

 April 14, 2022     angular, migration     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing