import { Component, OnInit, Input, ViewChild } from '@angular/core' import { trigger, state, style, animate, transition } from '@angular/animations' @Component({ selector: 'nav-item', templateUrl: './nav-item.component.html', styleUrls: ['./nav-item.component.scss'], animations: [ trigger('inOut', [ transition('void => *', [ style({ opacity: 0, height: 0 }), animate(500, style({ opacity: 1, height: '*' })) ]), transition('* => void', [ style({ opacity: 1, height: '*' }), animate(500, style({ opacity: 0, height: 0 })) ]) ]) ] }) export class NavItemComponent implements OnInit { @Input() menu: any ngOnInit() {} toggleExpand(menuItem) { menuItem.expand = !menuItem.expand } }