Search code examples
androidiosionic2swipe

Ionic2 how to enable swipe ONLY for moving back?


I made my app by using the below code at the first time.

ionic start MyApp sidemenu --v2

And I added several pages. Some pages having components to push to another pages. For simplification, assume that page hierarchy is like below.

side menu -> page1 -> page2 -> page3  
side menu -> page4  
side menu -> page5  

In page2 or page3, I want the users to go back to page1 or page2 by swiping. In page1, page4, or page5, I want the users to open side menu by swiping. But in tutorial implementation, I always open side menu by swiping.

How should I do now? I am sorry for my deficient English.

Thanks in advance.


Solution

  • import { IonicApp, IonicModule } from 'ionic-angular';
    
    @NgModule({
      declarations: [ MyApp ],
      imports: [
        IonicModule.forRoot(MyApp, {
         swipeBackEnabled: 'true' //here it will help you to solve the swip
        }, {}
      )],
      bootstrap: [IonicApp],
      entryComponents: [ MyApp ],
      providers: []
    })
    

    check this link http://ionicframework.com/docs/v2/api/components/nav/Nav/ you can make it enable for swipe mode