Ionic2: How to use an different ion-menu in each child view

后端 未结 2 1910
礼貌的吻别
礼貌的吻别 2021-01-01 04:25

I am trying to learn the use of the Ionic2 side menus and wish to see if I can have a separate side menu in each child view.

I have installed one of the getting star

2条回答
  •  不知归路
    2021-01-01 04:51

    Just adding this as part of info given by @sebaferreras for the sake of @user623396

    To have the side menu in the actual view, I had the following...

        
          
            Title
          
    
          
            
              
                    
            
          
        
    
        
          
          Getting Started
        
    
        
          
    Some text

    And then in the component file

        import {Component} from '@angular/core';
        import {MenuController, NavController} from 'ionic-angular';
    
        // Use the pipe TranslatePipe to use in the markup
        @Component({
          templateUrl: 'build/pages/sidemenu-page/sidemenu-page.html'
        })
        export class SideMenuPage {
          public rootPage = SideMenuPage;
    
          public myVal: string;  
    
          constructor(private menu: MenuController, private nav: NavController, private tranlate: TranslateService){
          }
    
          ionViewDidEnter() {
            this.menu.enable(true, 'menu1');
          }  
        }
    

    Hopefully this is still correct for the latest version of Ionic (it's been a while since I have looked at this example)

提交回复
热议问题