ncohen ncohen - 1 year ago 96
AngularJS Question

Can't make ng properties work in Angular 2

I'm using Angular 2 RC1 and I'm trying to use

. 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...


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

<li *ngFor="#item of list">
  {{ item }}