mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-11 19:49:18 +08:00
fix(angular): adds tabs stack
This commit is contained in:
committed by
Manu MA
parent
d9172b7d68
commit
adae8d4ad1
@@ -87,6 +87,13 @@ Using tabs with Angular's router is fairly straight forward. The only additional
|
||||
<!-- Auto Generated Below -->
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Attribute | Description | Type | Default |
|
||||
| ----------- | ------------ | ----------- | --------- | ------- |
|
||||
| `useRouter` | `use-router` | | `boolean` | `false` |
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
| Event | Description | Detail |
|
||||
|
||||
@@ -11,7 +11,6 @@ export class Tabs implements NavOutlet {
|
||||
|
||||
private transitioning = false;
|
||||
private leavingTab?: HTMLIonTabElement;
|
||||
private useRouter = false;
|
||||
|
||||
@Element() el!: HTMLStencilElement;
|
||||
|
||||
@@ -21,6 +20,9 @@ export class Tabs implements NavOutlet {
|
||||
@Prop({ context: 'config' }) config!: Config;
|
||||
@Prop({ context: 'document' }) doc!: Document;
|
||||
|
||||
/** @internal */
|
||||
@Prop({ mutable: true }) useRouter = false;
|
||||
|
||||
/**
|
||||
* Emitted when the tab changes.
|
||||
*/
|
||||
@@ -42,7 +44,9 @@ export class Tabs implements NavOutlet {
|
||||
@Event() ionNavDidChange!: EventEmitter<void>;
|
||||
|
||||
async componentWillLoad() {
|
||||
this.useRouter = !!this.doc.querySelector('ion-router') && !this.el.closest('[no-router]');
|
||||
if (!this.useRouter) {
|
||||
this.useRouter = !!this.doc.querySelector('ion-router') && !this.el.closest('[no-router]');
|
||||
}
|
||||
this.tabs = Array.from(this.el.querySelectorAll('ion-tab'));
|
||||
this.ionNavWillLoad.emit();
|
||||
this.componentWillUpdate();
|
||||
@@ -69,9 +73,9 @@ export class Tabs implements NavOutlet {
|
||||
protected onTabClicked(ev: CustomEvent<TabButtonClickDetail>) {
|
||||
const { href, tab } = ev.detail;
|
||||
const selectedTab = this.tabs.find(t => t.tab === tab);
|
||||
if (this.useRouter && href !== undefined) {
|
||||
if (this.useRouter) {
|
||||
const router = this.doc.querySelector('ion-router');
|
||||
if (router) {
|
||||
if (router && href !== undefined) {
|
||||
router.push(href);
|
||||
}
|
||||
} else if (selectedTab) {
|
||||
|
||||
Reference in New Issue
Block a user