Ionic 2 passing tabs NavParams to tab

前端 未结 5 620
名媛妹妹
名媛妹妹 2020-12-04 23:43

I\'m starting out on creating my first app using Ionic 2 and through a lot of trial and error have got to a point where no number of Google searching can find anything to

5条回答
  •  失恋的感觉
    2020-12-05 00:31

    For those who haven't figured out yet .....

    I've searched a lot and the only answer I got was using native storage or using a service or session storage...but that wasn't what I wanted ... So, If you have data in NavParams in Tabs.ts page and want to it pass as [rootParam] to respective Tabs... then what you need to do is instead of assigning NavParams to a variable in Tabs.ts page what you can do is bind it directly to the [rootParams] in the HTML page. Like ..

    tabs.ts

    constructor(public navParams: NavParams) { }
    

    tabs.html

    
    
    

    Or

    tabs.html

     
    

    tab1.ts

    constructor( public navParams: NavParams) {}
    
    ionViewDidLoad() {
      console.log('ionViewDidLoad tab1Page');
      console.log(this.navParams.data);
    }
    

提交回复
热议问题