Answer the question
In order to leave comments, you need to log in
How to display ngFor under a certain element of another ngFor?
There is such a code
<div class="middle-content" *ngFor="let year of years">
<a class="middle-content_top-indent" (click)="log(year)">{{year}}</a>
<ul class="list-of-month" *ngFor="let month of months">
<li>
<span class="list-of-month__marker"></span>
<a href="#">{{month}}</a>
</li>
</ul>
</div>
Answer the question
In order to leave comments, you need to log in
As far as I understand, the list of months should expand by clicking on the year. Add the activeYear property, make the appropriate assignment in the click handler, and add to the list of months (by the way, you have a bug there - the list element is not ul, but li, so ngFor should be moved) add *ngIf="year === activeYear"
. Like so .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question