I have a Sidemenu with items and subitems. Currently, the subitems open by default but when I close one, it closes all the items together. I want to modify it so that only that specific item closes. The reopening functionality is working fine but I need the closing behavior to be the same.
Here is my HTML code:
<ng-container *ngIf="!item.hidden">
<li *ngIf="themeLayout === 'vertical'" data-username="dashboard Default Ecommerce CRM Analytics Crypto Project"
class="nav-item pcoded-hasmenu ng-tns-c20-2 ng-star-inserted pcoded-trigger" [routerLinkActive]="['active']">
<a [routerLinkActive]="['active']" href="javascript:" class="nav-link" (click)="navCollapse($event)">
<ng-container *ngTemplateOutlet="itemContent"></ng-container>
</a>
<ng-container *ngTemplateOutlet="subMenuContent"></ng-container>
</li>
...
component.ts
@Component({
selector: 'app-nav-collapse',
templateUrl: './nav-collapse.component.html',
styleUrls: ['./nav-collapse.component.scss'],
animations: [
trigger('slideInOut', [
transition(':enter', [
style({transform: 'translateY(-100%)', display: 'block'}),
animate('250ms ease-in', style({transform: 'translateY(0%)'}))
]),
transition(':leave', [
animate('250ms ease-in', style({transform: 'translateY(-100%)'}))
])
])
],
})
export class NavCollapseComponent implements OnInit {
...
}
Preview: