mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 10:01:59 +08:00
@ -1,4 +1,4 @@
|
||||
import { Directive, ElementRef, HostListener, Optional } from '@angular/core';
|
||||
import { Directive, HostListener, Optional } from '@angular/core';
|
||||
|
||||
import { NavController } from '../../providers/nav-controller';
|
||||
|
||||
@ -10,19 +10,16 @@ import { IonRouterOutlet } from './ion-router-outlet';
|
||||
})
|
||||
export class IonBackButtonDelegate {
|
||||
|
||||
set defaultHref(value: string | undefined | null) {
|
||||
this.elementRef.nativeElement.defaultHref = value;
|
||||
}
|
||||
get defaultHref(): string | undefined | null {
|
||||
return this.elementRef.nativeElement.defaultHref;
|
||||
}
|
||||
defaultHref: string | undefined | null;
|
||||
|
||||
constructor(
|
||||
@Optional() private routerOutlet: IonRouterOutlet,
|
||||
private navCtrl: NavController,
|
||||
private elementRef: ElementRef,
|
||||
private navCtrl: NavController
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@HostListener('click', ['$event'])
|
||||
onClick(ev: Event) {
|
||||
if (this.routerOutlet && this.routerOutlet.canGoBack()) {
|
||||
|
@ -49,6 +49,9 @@ export class IonTabs {
|
||||
private navCtrl: NavController,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@HostListener('ionRouterOutletActivated', ['$event.detail'])
|
||||
onPageSelected(detail: {view: RouteView}) {
|
||||
if (this.tabBar) {
|
||||
@ -69,4 +72,8 @@ export class IonTabs {
|
||||
animationDirection: 'back'
|
||||
});
|
||||
}
|
||||
|
||||
getSelected(): string | undefined {
|
||||
return this.outlet.getActiveStackId();
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,9 @@ export class RouterLinkDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@HostListener('click', ['$event'])
|
||||
onClick(ev: UIEvent) {
|
||||
this.navCtrl.setDirection(this.routerDirection);
|
||||
|
@ -1063,7 +1063,7 @@ ion-tab,prop,tab,string,undefined,true,false
|
||||
ion-tab,method,setActive,setActive() => Promise<void>
|
||||
|
||||
ion-tabs,shadow
|
||||
ion-tabs,method,getSelected,getSelected() => Promise<HTMLIonTabElement | undefined>
|
||||
ion-tabs,method,getSelected,getSelected() => Promise<string | undefined>
|
||||
ion-tabs,method,getTab,getTab(tab: string | HTMLIonTabElement) => Promise<HTMLIonTabElement | undefined>
|
||||
ion-tabs,method,select,select(tab: string | HTMLIonTabElement) => Promise<boolean>
|
||||
ion-tabs,event,ionChange,{tab: HTMLIonTabElement},true
|
||||
|
4
core/src/components.d.ts
vendored
4
core/src/components.d.ts
vendored
@ -4457,9 +4457,9 @@ export namespace Components {
|
||||
/**
|
||||
* Get the currently selected tab
|
||||
*/
|
||||
'getSelected': () => Promise<HTMLIonTabElement | undefined>;
|
||||
'getSelected': () => Promise<string | undefined>;
|
||||
/**
|
||||
* Get the tab at the given index
|
||||
* Get the tab element given the tab name
|
||||
*/
|
||||
'getTab': (tab: string | HTMLIonTabElement) => Promise<HTMLIonTabElement | undefined>;
|
||||
/**
|
||||
|
@ -49,12 +49,16 @@ export class Tab implements ComponentInterface {
|
||||
this.active = true;
|
||||
}
|
||||
|
||||
private prepareLazyLoaded(): Promise<HTMLElement | void> {
|
||||
private async prepareLazyLoaded(): Promise<HTMLElement | undefined> {
|
||||
if (!this.loaded && this.component != null) {
|
||||
this.loaded = true;
|
||||
return attachComponent(this.delegate, this.el, this.component, ['ion-page']);
|
||||
try {
|
||||
return attachComponent(this.delegate, this.el, this.component, ['ion-page']);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
hostData() {
|
||||
|
@ -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