9

Ionic 2 を使用しようとしていますが、アプリの読み込み中にタブを選択するなど、ほとんどの基本的なタスクにまだ苦労しています。

コントローラーを挿入してイベントTabsを呼び出そうとしましたが、役に立ちませんでした。selectonPageLoaded

誰かが助けてくれますか?

4

4 に答える 4

6
//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);
    }
}
于 2016-04-07T17:03:38.360 に答える