ngFor in Angular2
Hey...!! It's been a while since I posted my last article in CodeCircle. In web development,when fetching data from the database we use for loops basically.Use of for loops can be easily done using *ngFor in AngularJS. Lets see how we can easily use this in implementation. Set up your Angular environment as we did in previous articles. Now lets try simple examples to get aclear idea of using *ngFor. Example 1 :Print Set of fruits Define an array of fruits in your app.components.ts file as below. import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { public fruits = ['Apple', 'Grapes', 'Lemon', 'Oranges', 'Papaw']; } Now write the code for the *ngFor in your app.components.html file. <p *ngFor="let item of this.fruits">{{item}}</p> Outpu