39

Trying to run a *ngFor within the html like this. But, this error shows up.

Property binding ngForIn not used by any directive on an embedded template

This is the html code:

<ion-card *ngFor="#media in medias">

I've had this happen in my previous project as well, still figuring it out. Any clues?

Still new to Ionic2 & Angular2.

sebaferreras
  • 44,206
  • 11
  • 116
  • 134
Nick Snick
  • 911
  • 1
  • 9
  • 16
  • 3
    Possible duplicate of [Angular2 exception: Can't bind to 'ngForIn' since it isn't a known native property](http://stackoverflow.com/questions/34561168/angular2-exception-cant-bind-to-ngforin-since-it-isnt-a-known-native-proper) – Eric Martinez Jan 17 '16 at 22:30
  • 3
    Basically you have to do `#variable of array`, not `#variable in array` (`of` vs `in`) – Eric Martinez Jan 17 '16 at 22:33

1 Answers1

80

Your are mistaken with angular1 syntaxes:

Instead of *ngFor="#media in medias",

you have to write *ngFor="#media of medias"

UPDATE - as of beta.17, use the let syntax instead of #. This updates to the following:

<div *ngFor="let media of medias">

https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html

Raphael
  • 1,708
  • 13
  • 11