feat(navPush): navPush takes array for navParams

This commit is contained in:
Tim Lancina
2015-09-23 18:08:28 -05:00
parent 89c0a0ef09
commit 51fa25996c
2 changed files with 18 additions and 7 deletions

View File

@ -7,8 +7,7 @@ import {NavController} from './nav-controller';
@Directive({
selector: '[nav-push]',
properties: [
'navPush',
'pushData'
'navInstructions: navPush'
],
host: {
'(click)': 'onClick($event)',
@ -24,8 +23,23 @@ export class NavPush {
this.nav = nav;
}
set navInstructions(instructions) {
if (instructions instanceof Array) {
if (instructions.length > 2) {
throw 'Too many [nav-push] arguments, expects [View, { params }]'
}
this.destination = instructions[0];
this.navParams = instructions[1];
} else {
this.destination = instructions;
}
//let annotations = Reflect.getMetadata('annotations', view);
// TODO check to make sure destination is a Component/IonicView?
}
onClick(event) {
this.nav.push(this.navPush, this.pushData);
this.nav.push(this.destination, this.navParams);
}
}

View File

@ -17,7 +17,7 @@ import {NavParams, NavController} from 'ionic/ionic';
'<ion-content padding>' +
'<p>{{title}}</p>' +
'<p><button id="from1To2" primary (click)="push()">Push (Go to 2nd)</button></p>' +
'<p><button [push-data]="pushData" [nav-push]="pushPage">Push w/ nav-push (Go to 2nd)</button></p>' +
'<p><button [nav-push]="[pushPage, {id: 42}]">Push w/ nav-push (Go to 2nd)</button></p>' +
'<p><button (click)="setViews()">setViews() (Go to 3rd, no history)</button></p>' +
'<icon class="ion-ios-arrow-back"></icon>' +
'<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>' +
@ -34,9 +34,6 @@ class FirstPage {
this.title = 'First Page';
this.pushPage = SecondPage;
this.pushData = {
id: 420
}
}
setViews() {