1//if
2<div *ngIf='[condition]'> </div>
3 //if [condition]==true the div will be shown
4
5//for
6<div *ngFor='let [data] of [dataArray]; let i=index;'>
7 <h2> {{i}} {{data.title}} </h2>
8 <img src='{{data.image}}' />
9 </div>
10 //the data contained in an array will be displayed element by element
11 //similar to the function .map() in React
12
13// ngStyle (conditional Style)
14<div *ngFor='let [data] of [dataArray]; let i=index;'>
15 <h2 [style.background]="i>1? 'green': 'red'"> {{i}} {{data.title}} </h2>
16
17 </div>
18
19//if the index of the element is 1 or 0, the background will be red, if it is over 1 the background will be green
20
21
22