1

I am getting the following error while building the angular 11 project.

Can't bind to 'ngStyle' since it isn't a known property of 'div'.
<div class="list" [ngStyle]="{'max-height': maxheight + 'px'}">

Same error is coming for all templates.

For development build its working fine, but for prod getting those errors.

Any help would be appreciated.

Suraj Gupta
  • 437
  • 8
  • 19
  • 1
    Does this answer your question? [Angular2 Exception: Can't bind to 'ngStyle' since it isn't a known native property](https://stackoverflow.com/questions/36503654/angular2-exception-cant-bind-to-ngstyle-since-it-isnt-a-known-native-proper) – ruth Feb 19 '21 at 08:18
  • Take a look for [similar question](https://stackoverflow.com/questions/36503654/angular2-exception-cant-bind-to-ngstyle-since-it-isnt-a-known-native-proper) – Ibram Reda Feb 19 '21 at 08:18
  • i have checked almost all questions, nothing helped. when i do `ng build --prod` then only getting those errors. – Suraj Gupta Feb 19 '21 at 08:25
  • @SurajGupta could you solve this issue? – Merdan Gochmuradov Jul 20 '23 at 13:05

1 Answers1

0

You need to import CommonModule and FormsModule, even if it is a lazy-loaded module via SharedModule or directly

@NgModule({
  imports: [CommonModule, FormsModule],
  ...
})
Logan Young
  • 385
  • 2
  • 9