0

I'm using Angular 2 RC1 and I'm trying to use ngFor. I've imported import {Component, Input} from 'angular2/core'; and I know angular is working (I've tried to display a variable <div>{{ myVar }}</div> and it works)

I keep getting Can't bind to 'ngFor' since it isn't a known native property when doing:

<div *ngFor="let item of list">{{item}}</div>.

I've tried to import import {NgFor} from 'angular2/common'; and added it to my directives with no success.

The litterature online is confusing as it seems the Angular team has changed between beta versions and RC...

Nate
  • 7,606
  • 23
  • 72
  • 124
  • what's list? can you show us your component code? And RC1 should be imported via `@angular/core`. you're importing the beta version. – malifa May 26 '16 at 22:25
  • PS: -No need to import external `NgFor` all these imports are already in the CORE_DIRECTIVES. – Pardeep Jain May 27 '16 at 05:46

1 Answers1

1

You are importing from 'angular2/core' instead of '@angular/core', so you have to use '#' instead 'let':

<li *ngFor="#item of list">
  {{ item }}
</li>
Kayo Lima
  • 740
  • 7
  • 16
  • Good point! I just realized that and changed to `@angular/core`. The problem now is that I'm getting a 500 error from the server (I did the `npm install` and added all the @angular to my package.json) – Nate May 27 '16 at 00:48
  • Try cloning from https://github.com/angular/quickstart.git and start your project from that – Kayo Lima May 27 '16 at 01:14
  • Thanks, I didn't expect so many changes in the initialization phase. Please close the `li` – Nate May 27 '16 at 03:04
  • @ncohen For more List of updated Imports you can see here http://stackoverflow.com/a/34697758/5043867 – Pardeep Jain May 27 '16 at 05:47