Angular 2 Tutorial 13: *ngFor

preview_player
Показать описание
Learn what is *ngFor in Angular 2 and how to make use of it in your angular 2 application.
Рекомендации по теме
Комментарии
Автор

now in recent version you have to give datatype for for loop variable

<p *ngFor="let movie of moviesList"> {{movie}} </p>

Example


@Component({
selector: 'myMovies',
template: `<h1> top Movies </h1>

<p *ngFor="let movie of moviesList"> {{movie}} </p>

<div *ngIf="PremiumAccount"> You are now visible baseis on condition </div>`,
styleUrls:
})

export class MyMovieComponent {
PremiumAccount: boolean = false;
public moviesList: string[] = ['batman', 'Superman', 'Spiderman'];
}

neilsukalikar
Автор

Hey Nilesh Sukalikar...thnx fr the code given...i've used ur code..it works....can u suggest me any site that provides the new version coding for angular2..i am beginner for

mhvid
Автор

i have written same program but it does not give me the output...only loading is printed on browser




@Component({ selector: 'app-root', template: '<h1>welcome to movie hall</h1><p>we have following movie</p><ul><li *ngFor="#movie in '
})export class AppComponent { public movieList=['Batman', 'spiderman', 'wrong turn', 'titanic']}

mhvid