feature(angular): nav-params integrate with router

This commit is contained in:
Dan Bucholtz
2018-02-13 15:05:12 -06:00
parent f4d1c6f561
commit 8c8b8548e7
5 changed files with 57 additions and 16 deletions

View File

@ -1,5 +1,5 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { NavController } from '@ionic/angular';
import { NavController, NavParams } from '@ionic/angular';
@Component({
selector: 'page-three',
@ -12,6 +12,9 @@ import { NavController } from '@ionic/angular';
</ion-header>
<ion-content padding>
Page Three {{ts}}
<div>isProd: {{isProd}}</div>
<div>paramOne: {{paramOne}}</div>
<div>paramTwo: {{paramTwo}}</div>
<div>
<ion-button (click)="navPop()">Go Back</ion-button>
</div>
@ -22,7 +25,14 @@ import { NavController } from '@ionic/angular';
export class PageThree {
ts: number;
constructor(private navController: NavController) {
isProd = false;
paramOne: any = null;
paramTwo: any = null;
constructor(private navController: NavController, private navParams: NavParams) {
this.isProd = navParams.get('isProd');
this.paramOne = navParams.get('paramOne');
this.paramTwo = navParams.get('paramTwo');
setInterval(() => {
this.ts = Date.now();

View File

@ -30,7 +30,7 @@ export class PageTwo {
}
pushPageThreeComponent() {
this.navController.push('/simple-nav/page-three');
this.navController.push('/simple-nav/page-three/jim/halpert');
}
goBack() {

View File

@ -10,7 +10,7 @@ const routes: Routes = [
children: [
{ path: 'page-one', loadChildren: './page-one/page-one.module#PageOneModule' },
{ path: 'page-two', loadChildren: './page-two/page-two.module#PageTwoModule' },
{ path: 'page-three', loadChildren: './page-three/page-three.module#PageThreeModule' }
{ path: 'page-three/:paramOne/:paramTwo', loadChildren: './page-three/page-three.module#PageThreeModule', data: { isProd: true} }
]
},
];