Say I have a simple component with a single property which holds an array of numbers:
class AppComponent {
numbers: number[] = [1, 2, 3, 4, 5]
}
I want to display the odd numbers apart from the even numbers. Here's the template I currently have:
<div *ngFor="let number of numbers">
<div>
<h1>Odd Numbers</h1>
<ul></ul>
</div>
<div>
<h1>Even Numbers</h1>
<ul></ul>
</div>
</div>
The numbers should be listed as li items in the uls.
Also, if the array contains only even numbers, the 2nd div shouldn't be displayed.
Is this possible without storing 2 separate parts of the array?