mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
@ -176,19 +176,19 @@ Using tabs with Angular's router is fairly straight forward. Here you only need
|
||||
|
||||
## Methods
|
||||
|
||||
### `getSelected() => Promise<HTMLIonTabElement | undefined>`
|
||||
### `getSelected() => Promise<string | undefined>`
|
||||
|
||||
Get the currently selected tab
|
||||
|
||||
#### Returns
|
||||
|
||||
Type: `Promise<HTMLIonTabElement | undefined>`
|
||||
Type: `Promise<string | undefined>`
|
||||
|
||||
|
||||
|
||||
### `getTab(tab: string | HTMLIonTabElement) => Promise<HTMLIonTabElement | undefined>`
|
||||
|
||||
Get the tab at the given index
|
||||
Get the tab element given the tab name
|
||||
|
||||
#### Parameters
|
||||
|
||||
|
||||
@ -99,6 +99,29 @@ export class Tabs implements NavOutlet {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tab element given the tab name
|
||||
*/
|
||||
@Method()
|
||||
async getTab(tab: string | HTMLIonTabElement): Promise<HTMLIonTabElement | undefined> {
|
||||
const tabEl = (typeof tab === 'string')
|
||||
? this.tabs.find(t => t.tab === tab)
|
||||
: tab;
|
||||
|
||||
if (!tabEl) {
|
||||
console.error(`tab with id: "${tabEl}" does not exist`);
|
||||
}
|
||||
return tabEl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently selected tab
|
||||
*/
|
||||
@Method()
|
||||
getSelected(): Promise<string | undefined> {
|
||||
return Promise.resolve(this.selectedTab ? this.selectedTab.tab : undefined);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@Method()
|
||||
async setRouteId(id: string): Promise<RouteWrite> {
|
||||
@ -122,27 +145,6 @@ export class Tabs implements NavOutlet {
|
||||
return tabId !== undefined ? { id: tabId, element: this.selectedTab } : undefined;
|
||||
}
|
||||
|
||||
/** Get the tab at the given index */
|
||||
@Method()
|
||||
async getTab(tab: string | HTMLIonTabElement): Promise<HTMLIonTabElement | undefined> {
|
||||
const tabEl = (typeof tab === 'string')
|
||||
? this.tabs.find(t => t.tab === tab)
|
||||
: tab;
|
||||
|
||||
if (!tabEl) {
|
||||
console.error(`tab with id: "${tabEl}" does not exist`);
|
||||
}
|
||||
return tabEl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently selected tab
|
||||
*/
|
||||
@Method()
|
||||
getSelected(): Promise<HTMLIonTabElement | undefined> {
|
||||
return Promise.resolve(this.selectedTab);
|
||||
}
|
||||
|
||||
private async initSelect(): Promise<void> {
|
||||
if (this.useRouter) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user