Angular 将参数从一个页面传递到选项卡,然后传递到tabx
我试图将参数从一个页面传递到另一个选项卡页面,然后只传递到一个选项卡。 在这里,我将它从我的页面传递到选项卡页面:Angular 将参数从一个页面传递到选项卡,然后传递到tabx,angular,ionic-framework,ionic2,Angular,Ionic Framework,Ionic2,我试图将参数从一个页面传递到另一个选项卡页面,然后只传递到一个选项卡。 在这里,我将它从我的页面传递到选项卡页面: this.nav.setRoot(TabsNavigationPage, { nome: displayName }); 现在我在TabsPage读到了 this.displayName = navParams.get('nome'); 所以我编辑了html标签页 <ion-tab [root]="tab2Root" [rootParams]="displayNa
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>
但是它不起作用。有什么建议吗?您可以通过将其存储在本地存储器中轻松实现。您可以使用它 简单代码段:
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);
})
});
}
}
您可以通过将其存储在本地存储器中来轻松实现这一点 简单代码段:
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);
})
});
}
}
tabx是什么意思?tab2root应该与页面/组件相关联。您必须使用该组件中的navParams访问数据。@Aravind by tabx我的意思是tabx,其中x是一个数字。这只是一个tabBy tabx。您的意思是什么?tab2root应该与页面/组件相关联。您必须使用该组件中的navParams访问数据。@Aravind by tabx我的意思是tabx,其中x是一个数字。这只是一个tabx。对此有任何反馈吗?对此有任何反馈吗?