How to use for loop in angular 6
How to use for loop in angular 6 Easy way to use for loop in angular 6. The NgFor directive instantiates a template once per item from an iterable. 1) Simple array to use for loop in angular 6. app.component.ts export class AppComponent implements OnInit { users = ["Test1", "Test2", "Test3", "Test4"]; } app.component.html <ul> <li *ngFor="let user of users"> <h1>{{user}}</h1> </li> </ul> view 1) Object to use for loop in angular 6. app.component.ts export class AppComponent implements OnInit { users = [ {name: "David Gupta", age: "20"}, {name: "Sara Taylor", age: "20"} ]; } app.component.html <table> <tr *ngFor="let user of users"> <td><b>Name:</b> {{user.name}}</td> ...