import {Component, EventEmitter, Input, Output} from '@angular/core';
import { Router} from '@angular/router';
import {Subscription} from 'rxjs';

@Component({
  selector: 'pages-menu-item',
  templateUrl: 'pages-menu-item.component.html',
  styleUrls: ['pages-menu-item.component.scss', '../pages-menu.component.scss']
})
export class PagesMenuItemComponent {
  @Input() item: any;
  @Output() onSelected = new EventEmitter();
  showChildren = false;

  currentURL:string;
  constructor(private router: Router) {
    router.events.subscribe((event:any)=>{
      if(event.url)this.currentURL = event.url
    })
    this.currentURL = router.url
  }


  get children() {
    return this.item?.children?.data;
  }

  ngOnInit() {

  }

  select(item:any){
    this.onSelected.emit(item);
  }

}
