Property ngClass is not provided by any applicable directives nor by div element

Issue

If i want to use ngClass, ngStyle or ngIf i get the following errormessage:

Error Message

My app.module.ts includes BrowserModule and CommonModule imports. And my Components are in the declarations.

I tried restart ng serve and npm install.

ngModule

Any Ideas how to fix this?

Solution

As you said, everything works fine when your project is builded/launched in your browser. So it’s an issue with your IDE.

You have multiple solutions

  • update your Intellij, if it’s already updated …
  • … invalidate your cache, if it’s still doesn’t work
  • delete your node module and recreate it (this fixed your issue here https://youtrack.jetbrains.com/issue/WEB-51326)
  • reinstall it/create new project
  • or … switch to VSCode while Intellij is fixing your bug

Answered By – Pilpo

Answer Checked By – Candace Johnson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.