pass nav params

This commit is contained in:
Adam Bradley
2015-05-13 09:22:59 -05:00
parent ab2b78a99c
commit a9e966d0a8
5 changed files with 31 additions and 15 deletions

View File

@@ -22,7 +22,7 @@ export class NavBase {
set initial(Class) {
if (!this._init) {
this._init = true
this._init = true;
this.push(Class);
}
}
@@ -62,6 +62,10 @@ export class NavBase {
}
pop(opts = {}) {
if (this.items.length < 2) {
return Promise.reject();
}
let resolve;
let promise = new Promise(res => { resolve = res; });

View File

@@ -28,20 +28,19 @@ export class NavItem {
let promise = new Promise((res) => { resolve = res; });
let injector = this.nav.injector.resolveAndCreateChild([
bind(NavController).toValue(this.nav.navCtrl)
bind(NavController).toValue(this.nav.navCtrl),
bind(NavParams).toValue(new NavParams(this.params))
]);
this.nav.loader.loadNextToExistingLocation(this.Class, this.nav.itemContent.elementRef, injector)
.then((componentRef) => {
this.nav.loader.loadNextToExistingLocation(this.Class, this.nav.itemContent.elementRef, injector).then((componentRef) => {
// content
this.component = componentRef;
this.domElement = componentRef.location.domElement;
this.domElement.classList.add('nav-item');
this.domElement.setAttribute('data-nav-item-id', this.id);
this.created = true;
resolve();
});
@@ -61,3 +60,9 @@ export class NavItem {
}
}
export class NavParams {
constructor(params) {
util.extend(this, params);
}
}

View File

@@ -18,7 +18,7 @@ import {ToolbarContainer} from 'ionic/components/toolbar/toolbar';
})
@View({
template: `
<header class="toolbar-container" style="display:none">
<header class="toolbar-container">
<header-container></header-container>
</header>
<section class="nav-item-container">

View File

@@ -1,8 +1,8 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {View} from 'angular2/src/core/annotations_impl/view';
import {NavController} from 'ionic/ionic'
import {SecondPage} from './second-page'
import {NavController} from 'ionic/ionic';
import {SecondPage} from './second-page';
@Component({selector: 'ion-view'})
@@ -17,6 +17,6 @@ export class FirstPage {
}
push() {
this.nav.push(SecondPage, { animation: 'none' });
this.nav.push(SecondPage, { id: 8675309, myData: [1,2,3,4] }, { animation: 'ios' });
}
}

View File

@@ -1,8 +1,8 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {View} from 'angular2/src/core/annotations_impl/view';
import {NavController} from 'ionic/ionic'
import {ThirdPage} from './third-page'
import {NavController, NavParams} from 'ionic/ionic';
import {ThirdPage} from './third-page';
@Component()
@@ -12,14 +12,21 @@ import {ThirdPage} from './third-page'
})
export class SecondPage {
constructor(
nav: NavController
nav: NavController,
params: NavParams
) {
this.nav = nav
this.nav = nav;
this.params = params;
console.log('Second page params:', params);
}
pop() {
this.nav.pop();
}
push() {
this.nav.push(ThirdPage, { animation: 'none' });
this.nav.push(ThirdPage);
}
}