mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
docs(tabs): update to use ViewChild
This commit is contained in:
@ -103,7 +103,7 @@ import {isBlank, isTrueProperty} from '../../util/util';
|
|||||||
* example, set the value of `id` to `myTabs`:
|
* example, set the value of `id` to `myTabs`:
|
||||||
*
|
*
|
||||||
* ```html
|
* ```html
|
||||||
* <ion-tabs id="myTabs">
|
* <ion-tabs #myTabs>
|
||||||
* <ion-tab [root]="tab1Root"></ion-tab>
|
* <ion-tab [root]="tab1Root"></ion-tab>
|
||||||
* <ion-tab [root]="tab2Root"></ion-tab>
|
* <ion-tab [root]="tab2Root"></ion-tab>
|
||||||
* <ion-tab [root]="tab3Root"></ion-tab>
|
* <ion-tab [root]="tab3Root"></ion-tab>
|
||||||
@ -111,17 +111,16 @@ import {isBlank, isTrueProperty} from '../../util/util';
|
|||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Then in your class you can grab the `Tabs` instance and call `select()`,
|
* Then in your class you can grab the `Tabs` instance and call `select()`,
|
||||||
* passing the index of the tab as the argument. In the following code `app` is
|
* passing the index of the tab as the argument. Here we're grabbing the tabs
|
||||||
* of type [`IonicApp`](../../app/IonicApp/):
|
* by using ViewChild.
|
||||||
*
|
*
|
||||||
*```ts
|
*```ts
|
||||||
* constructor(app: IonicApp) {
|
* constructor() {
|
||||||
* this.app = app;
|
* @ViewChild('myTabs) tabRef: Tabs
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* onPageDidEnter() {
|
* onPageDidEnter() {
|
||||||
* let tabs = this.app.getComponent('myTabs');
|
* this.tabRef.select(2);
|
||||||
* tabs.select(2);
|
|
||||||
* }
|
* }
|
||||||
*```
|
*```
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user