2017-03-21 45 views
1

我想從一個頁面參數傳遞到標籤頁然後只是一個標籤。 所以在這裏我通過它從我的網頁標籤頁:將參數從一個頁面傳遞到標籤然後tabx

this.nav.setRoot(TabsNavigationPage, { nome: displayName }); 

現在TabsPage我讀它

this.displayName = navParams.get('nome'); 

所以我編輯的HTML標籤頁

<ion-tab [root]="tab2Root" [rootParams]="displayName" tabTitle="Profile" tabIcon="person"></ion-tab> 

Becouse林興趣例如,僅用於tab2。因此,在TABS2 TS我寫這篇文章:

this.displayName = navParams.data.displayName; 

但它不是做work.Any建議嗎?

+0

通過TABX你是什麼意思? – Aravind

+0

tab2root應該與頁面/組件關聯。您必須使用該組件中的navParams訪問數據。 – Deepak

+0

@Aravind tabx我的意思是tabx其中x是一個數字它只是一個選項卡 –

回答

0

您可以輕鬆地將其存儲在本地存儲中。您可以使用Storage module

簡單的代碼片段:

import { Storage } from '@ionic/storage'; 

export class MyApp { 
    constructor(storage: Storage) { 

    storage.ready().then(() => { 

     // set as you wish. 
     storage.set('nome', 'YourNome'); 

     // Do this part within Tabx component.Not here :D 
     storage.get('nome').then((val) => { 
     console.log('Your nome is', val); 
     }) 
    }); 
    } 
} 
+0

對此有任何反饋? – Sampath

相關問題