mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(navigation): add isTab check to getSegmentsFromNav
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: `<ion-nav [root]="root"></ion-nav>`
|
||||
})
|
||||
export class AppComponent {
|
||||
root = 'SecondNav';
|
||||
}
|
||||
17
src/components/nav/test/simple-nested-navs/app/app.module.ts
Normal file
17
src/components/nav/test/simple-nested-navs/app/app.module.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { IonicApp, IonicModule } from '../../../../..';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
IonicModule.forRoot(AppComponent, { swipeBackEnabled: true, preloadModules: true }),
|
||||
],
|
||||
bootstrap: [IonicApp]
|
||||
})
|
||||
export class AppModule {}
|
||||
5
src/components/nav/test/simple-nested-navs/app/main.ts
Normal file
5
src/components/nav/test/simple-nested-navs/app/main.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from '../../../../../..';
|
||||
import { FirstPage } from './first-page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicPageModule.forChild(FirstPage)
|
||||
],
|
||||
declarations: [
|
||||
FirstPage
|
||||
]
|
||||
})
|
||||
export class FirstPageModule { }
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController } from '../../../../../..';
|
||||
|
||||
@IonicPage()
|
||||
@Component({
|
||||
selector: 'page-home',
|
||||
template: `
|
||||
<ion-header>
|
||||
<ion-navbar>
|
||||
<ion-title>Tab 1</ion-title>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<button ion-button (click)="goToNextPage()">Go to Next Page</button>
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class FirstPage {
|
||||
|
||||
constructor(public navCtrl: NavController) {
|
||||
|
||||
}
|
||||
|
||||
goToNextPage() {
|
||||
this.navCtrl.push('ThirdNav');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from '../../../../../..';
|
||||
import { HomePage } from './home';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicPageModule.forChild(HomePage)
|
||||
],
|
||||
declarations: [
|
||||
HomePage
|
||||
]
|
||||
})
|
||||
export class HomePageModule { }
|
||||
@@ -0,0 +1,3 @@
|
||||
page-home {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController } from '../../../../../..';
|
||||
|
||||
@IonicPage()
|
||||
@Component({
|
||||
selector: 'page-home',
|
||||
template: `
|
||||
<ion-header>
|
||||
<ion-navbar>
|
||||
<ion-title>
|
||||
Ionic Blank
|
||||
</ion-title>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content padding>
|
||||
The world is your oyster.
|
||||
<p>
|
||||
If you get lost, the <a href="http://ionicframework.com/docs/v2">docs</a> will be your guide.
|
||||
</p>
|
||||
<button ion-button (click)="clickMe()">Go to Tabs</button>
|
||||
</ion-content>
|
||||
|
||||
`
|
||||
})
|
||||
export class HomePage {
|
||||
|
||||
constructor(public navCtrl: NavController) {
|
||||
|
||||
}
|
||||
|
||||
clickMe() {
|
||||
this.navCtrl.push('TabsPage', { paramOne: 'ParamOneData', paramTwo: 'ParamTwoData'});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from '../../../../../..';
|
||||
import { SecondNav } from './second-nav';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicPageModule.forChild(SecondNav)
|
||||
],
|
||||
declarations: [
|
||||
SecondNav
|
||||
]
|
||||
})
|
||||
export class SecondNavModule { }
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController } from '../../../../../..';
|
||||
|
||||
@IonicPage()
|
||||
@Component({
|
||||
selector: 'page-home',
|
||||
template: `
|
||||
<ion-nav [root]="rootPage"></ion-nav>
|
||||
|
||||
`
|
||||
})
|
||||
export class SecondNav {
|
||||
|
||||
rootPage:any = 'HomePage';
|
||||
constructor(public navCtrl: NavController) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from '../../../../../..';
|
||||
import { SecondPage } from './second-page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicPageModule.forChild(SecondPage)
|
||||
],
|
||||
declarations: [
|
||||
SecondPage
|
||||
]
|
||||
})
|
||||
export class SecondPageModule { }
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController } from '../../../../../..';
|
||||
|
||||
@IonicPage()
|
||||
@Component({
|
||||
selector: 'page-home',
|
||||
template: `
|
||||
<ion-header>
|
||||
<ion-navbar>
|
||||
<ion-title>Tab 2</ion-title>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
Second Page
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class SecondPage {
|
||||
|
||||
constructor(public navCtrl: NavController) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from '../../../../../..';
|
||||
import { TabsPage } from './tabs';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicPageModule.forChild(TabsPage)
|
||||
],
|
||||
declarations: [
|
||||
TabsPage
|
||||
]
|
||||
})
|
||||
export class TabsPageModule { }
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController, NavParams } from '../../../../../..';
|
||||
|
||||
@IonicPage({
|
||||
segment: 'toot/:paramOne/beep/:paramTwo'
|
||||
})
|
||||
@Component({
|
||||
template: `
|
||||
<ion-tabs>
|
||||
<ion-tab tabIcon="heart" [root]="tab1" tabTitle="Taco Burrito Enchilada"></ion-tab>
|
||||
<ion-tab tabIcon="star" [root]="tab2"></ion-tab>
|
||||
</ion-tabs>
|
||||
`
|
||||
})
|
||||
export class TabsPage {
|
||||
tab1 = 'FirstPage';
|
||||
tab2 = 'SecondPage';
|
||||
|
||||
constructor(public nav: NavController, public params: NavParams) {
|
||||
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
console.log('paramOne: ', this.params.data.paramOne);
|
||||
console.log('paramTwo: ', this.params.data.paramTwo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from '../../../../../..';
|
||||
import { ThirdNav } from './third-nav';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicPageModule.forChild(ThirdNav)
|
||||
],
|
||||
declarations: [
|
||||
ThirdNav
|
||||
]
|
||||
})
|
||||
export class ThirdNavModule { }
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController } from '../../../../../..';
|
||||
|
||||
@IonicPage()
|
||||
@Component({
|
||||
selector: 'page-home',
|
||||
template: `
|
||||
<ion-nav [root]="rootPage"></ion-nav>
|
||||
|
||||
`
|
||||
})
|
||||
export class ThirdNav {
|
||||
|
||||
rootPage:any = 'ThirdPage';
|
||||
constructor(public navCtrl: NavController) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from '../../../../../..';
|
||||
import { ThirdPage } from './third-page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicPageModule.forChild(ThirdPage)
|
||||
],
|
||||
declarations: [
|
||||
ThirdPage
|
||||
]
|
||||
})
|
||||
export class ThirdPageModule { }
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage, NavController } from '../../../../../..';
|
||||
|
||||
@IonicPage()
|
||||
@Component({
|
||||
selector: 'page-home',
|
||||
template: `
|
||||
<ion-header>
|
||||
<ion-navbar>
|
||||
<ion-title>Tab 1</ion-title>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
Third Page
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class ThirdPage {
|
||||
|
||||
constructor(public navCtrl: NavController) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -147,9 +147,11 @@ export class DeepLinker {
|
||||
if (isNav(nav)) {
|
||||
segments.push(this.getSegmentFromNav(nav as NavController));
|
||||
nav = nav.parent;
|
||||
} else {
|
||||
} else if (isTab(nav)) {
|
||||
segments.push(this.getSegmentFromTab(nav));
|
||||
nav = nav.parent && nav.parent.parent;
|
||||
} else {
|
||||
nav = nav.parent;
|
||||
}
|
||||
}
|
||||
return segments.reverse();
|
||||
|
||||
Reference in New Issue
Block a user