Esoy using the tabs in Ionic 2 but I can not pass parameters between them.
Currently, what I'm trying to do is to import the class that contains the tabs into one of the tabs and try to access a method of that class that returns the values.
Tabs.ts
import { Component } from '@angular/core';
import { NavParams, NavController } from 'ionic-angular';
import { ConfigPage } from '../config-page/config-page';
import { IndexPage } from '../index-page/index-page';
import { ProfilePage } from '../profile-page/profile-page';
import { Welcome } from '../welcome/welcome';
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
public datosTienda: any;
tab1Root: any = ConfigPage;
tab2Root: any = IndexPage;
tab3Root: any = ProfilePage;
constructor(
private navParams: NavParams,
private navController: NavController
) {}
ngOnInit(){
this.datosTienda = this.navParams.get('datosTienda');
}
getDatos(): any{
if(this.datosTienda != undefined) {
return this.datosTienda;
}
}
}
From welcome.ts come the store data, which I pass through the navController.push and I receive it without problem.
Index-page.ts:
import { Component } from '@angular/core';
import { NavParams } from 'ionic-angular';
import { TabsPage } from '../tabs/tabs';
@Component({
templateUrl: 'index-page.html',
})
export class IndexPage {
public datosTienda: any;
constructor(
public navParams: NavParams,
public tabsIns: TabsPage,
){ }
ngOnInit(){
this.datosTienda = this.tabsIns.getDatos();
console.log(this.datosTienda);
}
}
The error you are giving me is:
Can't resolve all parameters for IndexPage: ([object Object], ?)
Any ideas?