import { AfterViewInit , Component , ComponentFactoryResolver , ElementRef , ErrorHandler , Input , NgZone , Optional , Renderer , ViewChild , ViewContainerRef , ViewEncapsulation , forwardRef } from '@angular/core' ; import { App } from '../app/app' ; import { Config } from '../../config/config' ; import { DeepLinker } from '../../navigation/deep-linker' ; import { DomController } from '../../platform/dom-controller' ; import { GestureController } from '../../gestures/gesture-controller' ; import { Nav as INav } from '../../navigation/nav-interfaces' ; import { NavController } from '../../navigation/nav-controller' ; import { NavControllerBase } from '../../navigation/nav-controller-base' ; import { NavOptions } from '../../navigation/nav-util' ; import { Platform } from '../../platform/platform' ; import { TransitionController } from '../../transitions/transition-controller' ; import { ViewController } from '../../navigation/view-controller' ; import { RootNode } from '../split-pane/split-pane' ; name description usage Component demo see {@link /docs/components#navigation Navigation Component Docs} @ Component ( { selector : 'ion-nav' , template : '<div #viewport nav-viewport></div>' + '<div class="nav-decor"></div>' , encapsulation : ViewEncapsulation . None , providers : [ { provide : RootNode , useExisting : forwardRef ( ( ) => Nav ) } ] } ) export class Nav extends NavControllerBase implements AfterViewInit , RootNode , INav { private _root : any ; private _hasInit : boolean = false ; constructor ( @ Optional ( ) viewCtrl , @ Optional ( ) parent , app , config , plt , elementRef , zone , renderer , cfr , gestureCtrl , transCtrl , @ Optional ( ) linker , domCtrl , errHandler ) { super ( parent , app , config , plt , elementRef , zone , renderer , cfr , gestureCtrl , transCtrl , linker , domCtrl , errHandler ) ; if ( viewCtrl ) { viewCtrl . _setContent ( this ) ; } if ( parent ) { parent . registerChildNav ( this ) ; } else if ( viewCtrl && viewCtrl . getNav ( ) ) { this . parent = viewCtrl . getNav ( ) ; this . parent . registerChildNav ( this ) ; } else if ( app && ! app . getRootNavById ( this . id ) ) { app . registerRootNav ( this ) ; } } hidden @ ViewChild ( 'viewport' , { read : ViewContainerRef } ) set _vp ( val ) { this . setViewport ( val ) ; } ngAfterViewInit ( ) { this . _hasInit = true ; const segment = this . _linker . getSegmentByNavIdOrName ( this . id , this . name ) ; if ( segment && ( segment . component || segment . loadChildren ) ) { return this . _linker . initViews ( segment ) . then ( views => { return this . setPages ( views , null , null ) ; } ) ; } else if ( this . _root ) { const setUrl = segment ? false : true ; return this . push ( this . _root , this . rootParams , { isNavRoot : ( < any > this . _app . getRootNavById ( this . id ) === this ) , updateUrl : setUrl } , null ) ; } } input @ Input ( ) get root ( ) : any { return this . _root ; } set root ( page ) { this . _root = page ; if ( this . _hasInit ) { this . setRoot ( page ) ; } } input @ Input ( ) rootParams : any ; input @ Input ( ) name : string ; hidden ngOnDestroy ( ) { this . destroy ( ) ; } initPane ( ) { const isMain = this . _elementRef . nativeElement . hasAttribute ( 'main' ) ; return isMain ; } paneChanged ( isPane ) { if ( isPane ) { this . resize ( ) ; } } goToRoot ( opts ) { return this . setRoot ( this . _root , this . rootParams , opts , null ) ; } getType ( ) { return 'nav' ; } getSecondaryIdentifier ( ) { return null ; } }