mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
feat(navPush): navPush takes array for navParams
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
Reference in New Issue
Block a user