Reputation: 11308
In Angular 1, the ngIf and ngRepeat directives would create their own scope and you had to be careful when accessing scope variable inside these.
Are there any similar gotcha's in Angular 2 using *ngIf or *ngFor?
Upvotes: 1
Views: 2676
Reputation: 364727
No, because there are no scopes in Angular 2, thankfully. In Angular 2, the context for NgIf and NgFor is simply the component.
The only possible gotcha I've seen is described here: Angular2, *ngIf and local template variables
So, if you define a local template variable inside NgFor, note that it can only be used inside the template block (i.e., sibling and/or child elements inside the template block).
Upvotes: 4