By default when we use ngFor, the newest item is displayed below the first element.
For example a list contain: [Apple, Orange, Banana]
Using ngFor will display the list in order of-->
- Apple
- Orange
- Banana
I would like to know a way to reverse the order and display the very last element (or any new elements that are pushed on top while the older elements are automatically moved below). i.e.
- Banana
- Orange
- Apple
HTML:
<button (click)="deposit()">Deposit</button><br>
<button (click)="withdraw()">Withdraw</button>
<p>{{balance}}</p>
<p *ngFor="let element of transactions">{{element}}</p>
<router-outlet></router-outlet>
CSS:
.example {
background-color: #eee;
width: 200px;
height: 100px;
border: 1px dotted black;
overflow: scroll; /* Add the ability to scroll */
-ms-overflow-style: none;
scrollbar-width: none;
direction: ltr;
}
.example::-webkit-scrollbar {
display: none;
}
Would appreciate if anyone could suggest a CSS attribute that once the list is overflown the oldest elements below "fade" away and can be seen only when we scroll down.