import { ChangeDetectionStrategy , Component , Inject , Optional } from '@angular/core' ; import { LayoutFacade } from '../../../layout-core/+state/layout.facade' ; import { NavLink } from '../../interfaces/nav-link.interface' ; import { NAV_LINKS } from '../../layouts.tokens' ; @ Component ( { selector : 'medium-stories-nav-menu' , templateUrl : './nav-menu.component.html' , styleUrls : [ './nav-menu.component.scss' ] , changeDetection : ChangeDetectionStrategy . OnPush } ) export class NavMenuComponent { constructor ( public layoutFacade , @ Optional ( ) @ Inject ( NAV_LINKS ) public navLinks ) { } param index onMouseenter ( index ) { const showedSubmenu = this . navLinks [ index ] && this . navLinks [ index ] . children && this . navLinks [ index ] . children . length > 0 ; this . layoutFacade . setNavItem ( { id : 'nav' , index , showedSubmenu : ! ! showedSubmenu , level : 0 } ) ; } param index onMouseleave ( index ) { if ( this . navLinks [ index ] && ( ! this . navLinks [ index ] . children || ! this . navLinks [ index ] . children . length ) ) { this . layoutFacade . hideSubMenu ( ) ; } } }