From 51fa25996cdab1e216278281ca67301a98e259e1 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Wed, 23 Sep 2015 18:08:28 -0500 Subject: [PATCH] feat(navPush): navPush takes array for navParams --- ionic/components/nav/nav-push.ts | 20 +++++++++++++++++--- ionic/components/nav/test/basic/index.ts | 5 +---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ionic/components/nav/nav-push.ts b/ionic/components/nav/nav-push.ts index 0c97f6fff3..3917283d6d 100644 --- a/ionic/components/nav/nav-push.ts +++ b/ionic/components/nav/nav-push.ts @@ -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); } } diff --git a/ionic/components/nav/test/basic/index.ts b/ionic/components/nav/test/basic/index.ts index 572a876891..13aaa21019 100644 --- a/ionic/components/nav/test/basic/index.ts +++ b/ionic/components/nav/test/basic/index.ts @@ -17,7 +17,7 @@ import {NavParams, NavController} from 'ionic/ionic'; '' + '

{{title}}

' + '

' + - '

' + + '

' + '

' + '' + '' + @@ -34,9 +34,6 @@ class FirstPage { this.title = 'First Page'; this.pushPage = SecondPage; - this.pushData = { - id: 420 - } } setViews() {