I'm trying to use a nested *ngFor in my Angular project to render a dynamic menu. I'm trying something like this:
<li class="treeview" *ngFor="let pm of parentMenu">
<a href="#">
<i class="fa fa-edit"></i> <span>{{pm.MenuTitle}}</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu" *ngFor="let cm of childMenu">
<li *ngIf="cm.ParentMenuId == pm.Id">{{cm.MenuTitle}}</li>
</ul>
</li>
I'm only getting the first element of childMenu, my understanding was *ngFor works similar to foreach in C#, but clearly, that's not the case. Could someone please help me fix the code and understand it?
*ngIf works similar to foreachI guess you mean*ngFor, which does indeed work like aforEach.*ngIfworks like anif(no surprises here)