mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 01:52:19 +08:00
test(tabs): add lazy load ng-router angular tabs
This commit is contained in:
@ -22,6 +22,7 @@ const routes: Routes = [
|
||||
|
||||
{ path: 'no-routing-nav', loadChildren: './no-routing-nav/no-routing-nav.module#NoRoutingNavModule' },
|
||||
{ path: 'simple-nav', loadChildren: './simple-nav/simple-nav.module#SimpleNavModule' },
|
||||
{ path: 'lazy-load-tabs', loadChildren: './lazy-load-tabs/tabs.module#TabsModule' },
|
||||
{ path: 'simple-tabs', loadChildren: './simple-tabs/tabs.module#TabsModule' },
|
||||
{ path: 'static-tabs', loadChildren: './static-tabs/tabs.module#TabsModule' },
|
||||
];
|
||||
|
@ -50,7 +50,21 @@
|
||||
<a href="simple-nav/page-one">Simple Nav</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="simple-tabs">Simple Tabs</a>
|
||||
<a href="lazy-load-tabs">Lazy Loaded Route Tabs</a>
|
||||
<ul>
|
||||
<li>
|
||||
<a [routerLink]="['/lazy-load-tabs', 'tabs', { outlets: { tab1: ['mustang'] } }]">Tab 1</a>
|
||||
</li>
|
||||
<li>
|
||||
<a [routerLink]="['/lazy-load-tabs', 'tabs', { outlets: { tab2: ['camaro'] } }]">Tab 2</a>
|
||||
</li>
|
||||
<li>
|
||||
<a [routerLink]="['/lazy-load-tabs', 'tabs', { outlets: { tab3: ['charger'] } }]">Tab 3</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="simple-tabs">Simple Route Tabs</a>
|
||||
<ul>
|
||||
<li>
|
||||
<a [routerLink]="['/simple-tabs', 'tabs', { outlets: { tab1: ['mustang'] } }]">Tab 1</a>
|
||||
|
15
angular/test/nav/src/app/lazy-load-tabs/camaro/camaro-routing.module.ts
Executable file
15
angular/test/nav/src/app/lazy-load-tabs/camaro/camaro-routing.module.ts
Executable file
@ -0,0 +1,15 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { CamaroPage } from './camaro.page';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: CamaroPage, outlet: 'tab2' }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes), IonicModule],
|
||||
exports: [RouterModule, IonicModule]
|
||||
})
|
||||
export class CamaroPageRoutingModule { }
|
19
angular/test/nav/src/app/lazy-load-tabs/camaro/camaro.module.ts
Executable file
19
angular/test/nav/src/app/lazy-load-tabs/camaro/camaro.module.ts
Executable file
@ -0,0 +1,19 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { CamaroPage } from './camaro.page';
|
||||
import { CamaroPageRoutingModule } from './camaro-routing.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
CamaroPageRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
CamaroPage
|
||||
]
|
||||
})
|
||||
export class CamaroModule {}
|
17
angular/test/nav/src/app/lazy-load-tabs/camaro/camaro.page.ts
Executable file
17
angular/test/nav/src/app/lazy-load-tabs/camaro/camaro.page.ts
Executable file
@ -0,0 +1,17 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'camaro-page',
|
||||
template: `
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Camaro</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
Camaro
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class CamaroPage {}
|
15
angular/test/nav/src/app/lazy-load-tabs/charger/charger-routing.module.ts
Executable file
15
angular/test/nav/src/app/lazy-load-tabs/charger/charger-routing.module.ts
Executable file
@ -0,0 +1,15 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { ChargerPage } from './charger.page';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: ChargerPage, outlet: 'tab3' }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes), IonicModule],
|
||||
exports: [RouterModule, IonicModule]
|
||||
})
|
||||
export class ChargerPageRoutingModule { }
|
19
angular/test/nav/src/app/lazy-load-tabs/charger/charger.module.ts
Executable file
19
angular/test/nav/src/app/lazy-load-tabs/charger/charger.module.ts
Executable file
@ -0,0 +1,19 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { ChargerPage } from './charger.page';
|
||||
import { ChargerPageRoutingModule } from './charger-routing.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
ChargerPageRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
ChargerPage
|
||||
]
|
||||
})
|
||||
export class ChargerModule {}
|
17
angular/test/nav/src/app/lazy-load-tabs/charger/charger.page.ts
Executable file
17
angular/test/nav/src/app/lazy-load-tabs/charger/charger.page.ts
Executable file
@ -0,0 +1,17 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'charger-page',
|
||||
template: `
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Charger</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
Charger
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class ChargerPage {}
|
15
angular/test/nav/src/app/lazy-load-tabs/mustang/mustang-routing.module.ts
Executable file
15
angular/test/nav/src/app/lazy-load-tabs/mustang/mustang-routing.module.ts
Executable file
@ -0,0 +1,15 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { MustangPage } from './mustang.page';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: MustangPage, outlet: 'tab1' }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes), IonicModule],
|
||||
exports: [RouterModule, IonicModule]
|
||||
})
|
||||
export class MustangPageRoutingModule { }
|
19
angular/test/nav/src/app/lazy-load-tabs/mustang/mustang.module.ts
Executable file
19
angular/test/nav/src/app/lazy-load-tabs/mustang/mustang.module.ts
Executable file
@ -0,0 +1,19 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { MustangPage } from './mustang.page';
|
||||
import { MustangPageRoutingModule } from './mustang-routing.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
MustangPageRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
MustangPage
|
||||
]
|
||||
})
|
||||
export class MustangModule {}
|
17
angular/test/nav/src/app/lazy-load-tabs/mustang/mustang.page.ts
Executable file
17
angular/test/nav/src/app/lazy-load-tabs/mustang/mustang.page.ts
Executable file
@ -0,0 +1,17 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'mustang-page',
|
||||
template: `
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Mustang</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
Mustang
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class MustangPage {}
|
44
angular/test/nav/src/app/lazy-load-tabs/tabs-routing.module.ts
Executable file
44
angular/test/nav/src/app/lazy-load-tabs/tabs-routing.module.ts
Executable file
@ -0,0 +1,44 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TabsPageComponent } from './tabs.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'tabs',
|
||||
component: TabsPageComponent,
|
||||
children: [
|
||||
{
|
||||
path: 'mustang',
|
||||
outlet: 'tab1',
|
||||
loadChildren: 'app/lazy-load-tabs/mustang/mustang.module#MustangModule'
|
||||
},
|
||||
{
|
||||
path: 'camaro',
|
||||
outlet: 'tab2',
|
||||
loadChildren: 'app/lazy-load-tabs/camaro/camaro.module#CamaroModule'
|
||||
},
|
||||
{
|
||||
path: 'charger',
|
||||
outlet: 'tab3',
|
||||
loadChildren: 'app/lazy-load-tabs/charger/charger.module#ChargerModule'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
redirectTo: '/lazy-load-tabs/tabs/(tab1:mustang)'
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild(routes)
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
]
|
||||
})
|
||||
export class TabsRoutingModule { }
|
7
angular/test/nav/src/app/lazy-load-tabs/tabs.component.ts
Executable file
7
angular/test/nav/src/app/lazy-load-tabs/tabs.component.ts
Executable file
@ -0,0 +1,7 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'tabs-root',
|
||||
templateUrl: 'tabs.html'
|
||||
})
|
||||
export class TabsPageComponent {}
|
19
angular/test/nav/src/app/lazy-load-tabs/tabs.html
Normal file
19
angular/test/nav/src/app/lazy-load-tabs/tabs.html
Normal file
@ -0,0 +1,19 @@
|
||||
<ion-app>
|
||||
|
||||
<ion-tabs>
|
||||
|
||||
<ion-tab title="Tab 1" icon="home">
|
||||
<ion-router-outlet name="tab1"></ion-router-outlet>
|
||||
</ion-tab>
|
||||
|
||||
<ion-tab title="Tab 2" icon="heart">
|
||||
<ion-router-outlet name="tab2"></ion-router-outlet>
|
||||
</ion-tab>
|
||||
|
||||
<ion-tab title="Tab 3" icon="star">
|
||||
<ion-router-outlet name="tab3"></ion-router-outlet>
|
||||
</ion-tab>
|
||||
|
||||
</ion-tabs>
|
||||
|
||||
</ion-app>
|
19
angular/test/nav/src/app/lazy-load-tabs/tabs.module.ts
Executable file
19
angular/test/nav/src/app/lazy-load-tabs/tabs.module.ts
Executable file
@ -0,0 +1,19 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TabsPageComponent } from './tabs.component';
|
||||
import { TabsRoutingModule } from './tabs-routing.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
TabsRoutingModule,
|
||||
],
|
||||
declarations: [
|
||||
TabsPageComponent,
|
||||
]
|
||||
})
|
||||
export class TabsModule {}
|
@ -26,6 +26,10 @@ const routes: Routes = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
redirectTo: '/simple-tabs/tabs/(tab1:mustang)'
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user