0

Just started working with Angular 2.0 beta version. I am getting error angular is not defined while adding directive : [angular.ngFor].

Adding the Plunker url http://plnkr.co/edit/ULHddLRqPFXvNG7NPo93?p=preview

Thanks in advance

Sangwin Gawande
  • 7,658
  • 8
  • 48
  • 66
Nidhin T T
  • 298
  • 2
  • 5
  • 15
  • 1
    Possible duplicate of [Can't bind to 'ng-forOf' since it isn't a known native property](http://stackoverflow.com/questions/34228971/cant-bind-to-ng-forof-since-it-isnt-a-known-native-property) – Günter Zöchbauer Jan 11 '16 at 10:14

2 Answers2

3

You don't need to specify the directive anymore since it's a core one. The name of the directive to use is ngFor instead of ng-for.

Your template:

<h2>{{teamName}}</h2>

<ul>
  {{players}}
  <li *ngFor="#player of players"> {{player}}</li>
</ul>

Your component:

(function(app) {
  app.AppComponent =
    ng.core.Component({
      selector: 'my-app',
      templateUrl: 'app/home.html',
    })
    .Class({
      constructor: function() {
        this.teamName = 'ManchesterUnited';
        this.players = ['Ronney','Mata','Depay','Jhones','Smalling','Schiderlin'];
      }
    });
})(window.app || (window.app = {}));

Hope it helps you, Thierry

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
1

Since alpha.52 templates are case-sensitive. Use ngFor instead. This change also applies to other directives (ngIf, ngModel, ...)

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567