Cannot get rootParams in ionic v2 tab page


#1

up vote
0
down vote
favorite
in ion-tabs

<ion-tab [root]="tab1Root" [rootParams]="{'id': '23'}"  tabIcon="chatbubbles"></ion-tab>

and in tab1Root Page js

    import {Page, NavController, Events, Config, Storage, LocalStorage, NavParams} from 'ionic/ionic';
    ...
    constructor(nav: NavController,config: Config, params: NavParams) {
        this.nav = nav;
        this.params = params;
        this.id = params.get('id');
    ...

and error in console

TypeError: Cannot read property 'id' of null


#2

You should access directly like this
constructor(
private navParams : NavParams
) {
this.id= navParams.data.id;

}


#3

I used service like navParams. But I will try this method. Thank You !