Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Last active March 17, 2016 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronksaunders/74909d9be4aa78882e5b to your computer and use it in GitHub Desktop.
Save aaronksaunders/74909d9be4aa78882e5b to your computer and use it in GitHub Desktop.
passing params
import {App, Platform } from 'ionic-angular';
import {RouteConfig, Location} from 'angular2/router';
import {HomePage} from './pages/home/home';
import {TabsPage} from './pages/tabs/tabs';
// https://angular.io/docs/ts/latest/api/core/Type-interface.html
import {Type} from 'angular2/core';
@App({
config: {} // http://ionicframework.com/docs/v2/api/config/Config/
})
@RouteConfig([
{ path: '/', component: HomePage, as: 'HomePage' },
{ path: '/tabs', component: TabsPage, as: 'Tabs' },
])
export class MyApp {}
<ion-navbar *navbar>
<ion-title>
HOME PAGE
</ion-title>
</ion-navbar>
<ion-content class="home">
<button (click)="clicked($event)" >HELP</button>
</ion-content>
import {Page, NavParams, NavController} from 'ionic-angular';
import {TabsPage} from '../tabs/tabs';
@Page({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
// this tells the tabs component which Pages
// should be each tab's root Page
constructor( public nav:NavController) {
}
// click to goto main tab page and pass params
clicked(event) {
event.preventDefault();
this.nav.push(TabsPage, { user:"Aaron"});
}
}
<ion-tabs >
<ion-tab [root]="tab1Root" [rootParams]="tab1Params" tabTitle="Tab 1" tabIcon="pulse"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="Tab 2" tabIcon="chatbubbles"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="Tab 3" tabIcon="cog"></ion-tab>
</ion-tabs>
import {Page, NavParams} from 'ionic-angular';
import {Page1} from '../page1/page1';
import {Page2} from '../page2/page2';
import {Page3} from '../page3/page3';
@Page({
templateUrl: 'build/pages/tabs/tabs.html'
})
export class TabsPage {
// this tells the tabs component which Pages
// should be each tab's root Page
tab1Root: any = Page1;
tab2Root: any = Page2;
tab3Root: any = Page3;
constructor(private params: NavParams) {
// got params when page was opened... set on the desired tab
this.tab1Params = params;
console.log(params)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment