I have an array of words with varying lengths. I am using ng-For to loop through the array and ng-if to display the words based on their lengths, but I am struggling to add titles to separate them.
Expected Outcome:
2 letter words: to, am, as...
3 letter words: the, bee, sin...
And so on...
This is what I have so far:
<div *ngIf="data">
<h2 class="title">{{data.letters}}</h2>
<ul class="wordList" *ngFor="let item of data.word">
<li *ngIf="item.length ==2">{{item}}</li>
<li *ngIf="item.length ==3">{{item}}</li>
<li *ngIf="item.length ==4">{{item}}</li>
<li *ngIf="item.length ==5">{{item}}</li>
<li *ngIf="item.length ==6">{{item}}</li>
<li *ngIf="item.length ==7">{{item}}</li>
<li *ngIf="item.length ==8">{{item}}</li>
<li *ngIf="item.length ==9">{{item}}</li>
<li *ngIf="item.length ==10">{{item}}</li>
<li *ngIf="item.length ==11">{{item}}</li>
<li *ngIf="item.length ==12">{{item}}</li>
<li *ngIf="item.length ==13">{{item}}</li>
<li *ngIf="item.length ==14">{{item}}</li>
</ul>
</div>
I know I should also use an index to iterate through the word sizes, but I will address that later :)