mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 10:41:13 +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';
|
import { NavController } from '../../providers/nav-controller';
|
||||||
|
|
||||||
@ -10,19 +10,16 @@ import { IonRouterOutlet } from './ion-router-outlet';
|
|||||||
})
|
})
|
||||||
export class IonBackButtonDelegate {
|
export class IonBackButtonDelegate {
|
||||||
|
|
||||||
set defaultHref(value: string | undefined | null) {
|
defaultHref: string | undefined | null;
|
||||||
this.elementRef.nativeElement.defaultHref = value;
|
|
||||||
}
|
|
||||||
get defaultHref(): string | undefined | null {
|
|
||||||
return this.elementRef.nativeElement.defaultHref;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Optional() private routerOutlet: IonRouterOutlet,
|
@Optional() private routerOutlet: IonRouterOutlet,
|
||||||
private navCtrl: NavController,
|
private navCtrl: NavController
|
||||||
private elementRef: ElementRef,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
@HostListener('click', ['$event'])
|
@HostListener('click', ['$event'])
|
||||||
onClick(ev: Event) {
|
onClick(ev: Event) {
|
||||||
if (this.routerOutlet && this.routerOutlet.canGoBack()) {
|
if (this.routerOutlet && this.routerOutlet.canGoBack()) {
|
||||||
|
@ -49,6 +49,9 @@ export class IonTabs {
|
|||||||
private navCtrl: NavController,
|
private navCtrl: NavController,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
@HostListener('ionRouterOutletActivated', ['$event.detail'])
|
@HostListener('ionRouterOutletActivated', ['$event.detail'])
|
||||||
onPageSelected(detail: {view: RouteView}) {
|
onPageSelected(detail: {view: RouteView}) {
|
||||||
if (this.tabBar) {
|
if (this.tabBar) {
|
||||||
@ -69,4 +72,8 @@ export class IonTabs {
|
|||||||
animationDirection: 'back'
|
animationDirection: 'back'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSelected(): string | undefined {
|
||||||
|
return this.outlet.getActiveStackId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,9 @@ export class RouterLinkDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
@HostListener('click', ['$event'])
|
@HostListener('click', ['$event'])
|
||||||
onClick(ev: UIEvent) {
|
onClick(ev: UIEvent) {
|
||||||
this.navCtrl.setDirection(this.routerDirection);
|
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-tab,method,setActive,setActive() => Promise<void>
|
||||||
|
|
||||||
ion-tabs,shadow
|
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,getTab,getTab(tab: string | HTMLIonTabElement) => Promise<HTMLIonTabElement | undefined>
|
||||||
ion-tabs,method,select,select(tab: string | HTMLIonTabElement) => Promise<boolean>
|
ion-tabs,method,select,select(tab: string | HTMLIonTabElement) => Promise<boolean>
|
||||||
ion-tabs,event,ionChange,{tab: HTMLIonTabElement},true
|
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
|
* 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>;
|
'getTab': (tab: string | HTMLIonTabElement) => Promise<HTMLIonTabElement | undefined>;
|
||||||
/**
|
/**
|
||||||
|
@ -49,12 +49,16 @@ export class Tab implements ComponentInterface {
|
|||||||
this.active = true;
|
this.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private prepareLazyLoaded(): Promise<HTMLElement | void> {
|
private async prepareLazyLoaded(): Promise<HTMLElement | undefined> {
|
||||||
if (!this.loaded && this.component != null) {
|
if (!this.loaded && this.component != null) {
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
|
try {
|
||||||
return attachComponent(this.delegate, this.el, this.component, ['ion-page']);
|
return attachComponent(this.delegate, this.el, this.component, ['ion-page']);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
}
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
hostData() {
|
hostData() {
|
||||||
|
@ -176,19 +176,19 @@ Using tabs with Angular's router is fairly straight forward. Here you only need
|
|||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
### `getSelected() => Promise<HTMLIonTabElement | undefined>`
|
### `getSelected() => Promise<string | undefined>`
|
||||||
|
|
||||||
Get the currently selected tab
|
Get the currently selected tab
|
||||||
|
|
||||||
#### Returns
|
#### Returns
|
||||||
|
|
||||||
Type: `Promise<HTMLIonTabElement | undefined>`
|
Type: `Promise<string | undefined>`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### `getTab(tab: string | HTMLIonTabElement) => Promise<HTMLIonTabElement | undefined>`
|
### `getTab(tab: string | HTMLIonTabElement) => Promise<HTMLIonTabElement | undefined>`
|
||||||
|
|
||||||
Get the tab at the given index
|
Get the tab element given the tab name
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
|
@ -99,6 +99,29 @@ export class Tabs implements NavOutlet {
|
|||||||
return true;
|
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 */
|
/** @internal */
|
||||||
@Method()
|
@Method()
|
||||||
async setRouteId(id: string): Promise<RouteWrite> {
|
async setRouteId(id: string): Promise<RouteWrite> {
|
||||||
@ -122,27 +145,6 @@ export class Tabs implements NavOutlet {
|
|||||||
return tabId !== undefined ? { id: tabId, element: this.selectedTab } : undefined;
|
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> {
|
private async initSelect(): Promise<void> {
|
||||||
if (this.useRouter) {
|
if (this.useRouter) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user