Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Can't bind to 'ngForIn' . Angular 4+

this question has already been said but unfortunately no answer worked for me.

Here is my problem (angular 5):

<option 
    *ngFor="let country in countries" 
    [value]="country.id" >
       {{'page.choose_country' | translate}} *
</option>

I have a simple code but it still shows me this error:

Can't bind to 'ngForIn' since it isn't a known property of 'option'.

It does not accept *ngFor in select (I tested in input same result)

I've found several answers like commModule and bowersModule that need to be imported into the module or put b..... I tried to find solutions here, but nothing works.

I hope you've understood me a little bit, despite my scary English. Thank you for your response

like image 602
mathiasF Avatar asked Nov 23 '17 14:11

mathiasF


People also ask

Can't bind to ngForIn since it isn t?

Since ngForIn isn't an attribute directive with an input property of the same name (like ngIf ), Angular then tries to see if it is a (known native) property of the template element, and it isn't, hence the error.

Can't bind to ngFor since it isn't a known property of table?

ngFor is not a known property would mean for whatever reason, ngFor cannot be recognized in the application. However, the real problem was that ngFor was recognised but the syntax of ngFor was wrong. Anyway, let's hope Angular team improves their logging in future updates.

Can't bind to Ngforof since it isn't a known property of Div Angular 12?

Explanation: This error occurs when you use ngIf/ ngFor in the component, where you have not imported CommonModule. Fix: To fix this you have to import the CommonModule in the module file which is used by that HTML file.


2 Answers

It needs to be of instead of in

*ngFor="let country of countries" 
like image 79
Günter Zöchbauer Avatar answered Oct 13 '22 19:10

Günter Zöchbauer


Change

*ngFor="let country in countries" 

to

*ngFor="let country of countries" 

There is no such thing ngForIn introduced from Angular side : Ref Link

like image 28
Vivek Doshi Avatar answered Oct 13 '22 19:10

Vivek Doshi