Ionic 2を使用しようとしていますが、アプリの読み込み中にタブを選択するなど、ほとんどの基本的なタスクでまだ苦労しています。Ionic 2の特定のタブを選択
私はTabs
コントローラを注入しようとしましたが、select
をonPageLoaded
イベントに呼び出そうとしましたが、役に立たなくなりました。
誰か助けてもらえますか?イオン2変更selectedIndexプロパティのタブにデフォルトに
Ionic 2を使用しようとしていますが、アプリの読み込み中にタブを選択するなど、ほとんどの基本的なタスクでまだ苦労しています。Ionic 2の特定のタブを選択
私はTabs
コントローラを注入しようとしましたが、select
をonPageLoaded
イベントに呼び出そうとしましたが、役に立たなくなりました。
誰か助けてもらえますか?イオン2変更selectedIndexプロパティのタブにデフォルトに
//importing tabs for manipuling our ion-tabs
import {Tabs} from 'ionic-angular';
@Page({
templateUrl: 'build/pages/page1/page1.html'
})
export class Page1
{
//provide Angular with metadata about things it should inject in the constructor
static get parameters()
{
return [[Tabs]];
}
//after injecting ,passing an instance of [Tabs] in the page constructor
constructor(tab) {
this.tab = tab;
}
//"onPageWillEnter" function fires every time a page becomes the active view.
onPageWillEnter()
{
//make the second tab selected From the first tab (within the current Page 'page1')
// 1 IS the index of the target tab
this.tab.select(1);
}
}
このリンクをご覧くださいhttps://webcake.co/page-lifecycle-hooks-in-ionic-2/ –
ようこそ。答えの一部としてコードを説明することを検討してください。 –
タクス@リチャード・エリクソン、十分に説明されていますか? :p –
:ページのロード時のタブについて
<ion-tabs [selectedIndex]="1">
<ion-tab [root]="tab1Root" tabTitle="Home" tabIcon="rewind"></ion-tab> <!-- Index 0-->
<ion-tab [root]="tab2Root" tabTitle="About" tabIcon="md-time"></ion-tab><!-- Index 1 (Selected)-->
<ion-tab [root]="tab3Root" tabTitle="Contacts" tabIcon="fastforward"></ion-tab><!-- Index 2-->
</ion-tabs>
ザ・選択されたタブになります。
あなたは、タブコントロールが定義されているページのコンストラクタに ``を呼び出す選択()する必要がイオン3では
var t: Tabs = this.nav.parent;
t.select(index);
を試してみて、角度4.
import { Tabs } from 'ionic-angular/navigation/nav-interfaces';
@ViewChild('myTabs') tabRef: Tabs; - With in the class about constructor.
this.tabRef.select(0, {}); // In the method where you want set tab.
。残念ながら、コントロールへの参照を取得する方法の例はありません。 –
もう少し詳しく説明できますか? –