Presenting a functional sidenav demo with Angular 2, TypeScript, and Material Design components. The sidenav features a UL, with the Sites and Users anchors expanding to display their own sub-list.
Here is the HTML code for the sidenav:
<md-sidenav #start mode="over" class="sideDrawer">
<ul class="sidenav">
<li><a>Dashboard</a></li>
<li>
<a (click)="sideNavClick()">Sites</a>
<div>
<ul *ngIf="clickedSites" class="sublist">
<li><a (click)='sideNavAlert()'>All Sites</a></li>
<li><a>Site Groups</a></li>
</ul>
</div>
</li>
<li>
<a (click)="sideNavClickUser()">Users</a>
<div>
<ul *ngIf="clickedUsers" class="sublist">
<li><a (click)="sideNavAlert()" >Add User</a></li>
<li><a>Edit User</a></li>
<li><a>Remove User</a></li>
</ul>
</div>
</li>
<li>
<a>Lights</a>
</li>
<li><a>Settings</a></li>
</ul>
</md-sidenav>
This is a basic version of the solution provided. The actual sidenav will include numerous navigation options, each with children that require toggling visibility. I aim to have only one sublist visible at any given time. Instead of manipulating boolean values for every sublist using *ngIf, I seek a more efficient approach within Angular 2. Although a CSS workaround is plausible, it may involve adding/removing classes individually from each list, similar to flipping boolean values in the alternate solution.
Any thoughts or suggestions?