⚠️ This lesson is retired and might contain outdated information.

Loop Through Angular 2 Components with ngFor

John Lindquist
InstructorJohn Lindquist
Share this video with your friends

Social Share Links

Send Tweet
Published 9 years ago
Updated 2 years ago

This lesson covers Angular 2’s version of looping through data in your templates: *ngFor. It’s conceptually the same as Angular 1’s ng-repeat, but you’ll find the syntax quite different as it aligns with #refs in Angular 2 and JavaScript “for of” loop.

Nils
Nils
~ 8 years ago

i dont really understand what the [TodoService] in main.ts gives us ?. We still need to import it in every "module"? that wants to use it. tnx

Leon
Leon
~ 8 years ago

The TodoService just contains the todo array. So 1 module pushes todo's into that Array, and the other module just displays the todos in the array on the page. Yeah it seems to be exactly like Angular 1, where you have to import a service into every Controller where you want to use it.

Goma Games
Goma Games
~ 8 years ago

in the latest version of angular2, instead of using

<li *ngFor="#todo of todoService.todos">

the new syntax should be

<li *ngFor="let todo of todoService.todos">
Markdown supported.
Become a member to join the discussionEnroll Today