mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(angular): tabs angular tests
This commit is contained in:
@ -20,7 +20,7 @@
|
||||
"url": "https://github.com/ionic-team/ionic.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run clean && npm run ionic-core && npm run compile && npm run clean-generated",
|
||||
"build": "npm run clean && npm run compile && npm run clean-generated && npm run ionic-core",
|
||||
"build.link": "npm run build && node scripts/link-copy.js",
|
||||
"clean": "node scripts/clean.js",
|
||||
"clean-generated": "node ./scripts/clean-generated.js",
|
||||
|
@ -9,6 +9,7 @@ export { GoBack } from './navigation/go-back';
|
||||
export { IonBackButton } from './navigation/ion-back-button';
|
||||
export { NavDelegate } from './navigation/nav-delegate';
|
||||
export { TabDelegate } from './navigation/tab-delegate';
|
||||
export { TabsDelegate } from './navigation/tabs-delegate';
|
||||
export { IonRouterOutlet } from './navigation/ion-router-outlet';
|
||||
|
||||
export { Icon } from './icon';
|
||||
|
@ -12,7 +12,7 @@ export class IonBackButton {
|
||||
|
||||
@HostListener('click')
|
||||
onClick() {
|
||||
if (this.routerOutlet.canGoBack()) {
|
||||
if (this.routerOutlet && this.routerOutlet.canGoBack()) {
|
||||
this.routerOutlet.pop();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { ComponentFactoryResolver, Directive, ElementRef, HostListener, Injector, Optional } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { ComponentFactoryResolver, Directive, ElementRef, Injector } from '@angular/core';
|
||||
import { AngularDelegate } from '../../providers/angular-delegate';
|
||||
|
||||
|
||||
@ -9,7 +8,6 @@ import { AngularDelegate } from '../../providers/angular-delegate';
|
||||
export class TabDelegate {
|
||||
|
||||
constructor(
|
||||
@Optional() private router: Router,
|
||||
ref: ElementRef,
|
||||
cfr: ComponentFactoryResolver,
|
||||
injector: Injector,
|
||||
@ -18,15 +16,5 @@ export class TabDelegate {
|
||||
ref.nativeElement.delegate = angularDelegate.create(cfr, injector);
|
||||
}
|
||||
|
||||
@HostListener('ionTabbarClick', ['$event'])
|
||||
ionTabbarClick(ev: UIEvent) {
|
||||
const tabElm: HTMLIonTabElement = ev.detail as any;
|
||||
if (this.router && tabElm && tabElm.href) {
|
||||
console.log('tabElm', tabElm.href);
|
||||
|
||||
this.router.navigateByUrl(tabElm.href);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
22
angular/src/directives/navigation/tabs-delegate.ts
Normal file
22
angular/src/directives/navigation/tabs-delegate.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Directive, HostListener, Optional } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Directive({
|
||||
selector: 'ion-tabs'
|
||||
})
|
||||
export class TabsDelegate {
|
||||
|
||||
constructor(
|
||||
@Optional() private router: Router,
|
||||
) {}
|
||||
|
||||
@HostListener('ionTabbarClick', ['$event'])
|
||||
ionTabbarClick(ev: UIEvent) {
|
||||
const tabElm: HTMLIonTabElement = ev.detail as any;
|
||||
if (this.router && tabElm && tabElm.href) {
|
||||
this.router.navigateByUrl(tabElm.href);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ const DECLARATIONS = [
|
||||
c.IonRouterOutlet,
|
||||
c.NavDelegate,
|
||||
c.TabDelegate,
|
||||
c.TabsDelegate,
|
||||
|
||||
// virtual scroll
|
||||
c.VirtualFooter,
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
<ion-tabs>
|
||||
|
||||
<ion-tab title="Tab 1" icon="home">
|
||||
<ion-tab tabTitle="Tab 1" tabIcon="home" href="/lazy-load-tabs/tabs/(tab1:mustang)">
|
||||
<ion-router-outlet name="tab1"></ion-router-outlet>
|
||||
</ion-tab>
|
||||
|
||||
<ion-tab title="Tab 2" icon="heart">
|
||||
<ion-tab tabTitle="Tab 2" tabIcon="heart" href="/lazy-load-tabs/tabs/(tab2:camaro)">
|
||||
<ion-router-outlet name="tab2"></ion-router-outlet>
|
||||
</ion-tab>
|
||||
|
||||
<ion-tab title="Tab 3" icon="star">
|
||||
<ion-tab tabTitle="Tab 3" tabIcon="star" href="/lazy-load-tabs/tabs/(tab3:charger)">
|
||||
<ion-router-outlet name="tab3"></ion-router-outlet>
|
||||
</ion-tab>
|
||||
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
<ion-tabs>
|
||||
|
||||
<ion-tab title="Tab 1" icon="home">
|
||||
<ion-tab tabTitle="Tab 1" tabIcon="home" href="/lazy-load-tabs/tabs/(tab1:mustang)">
|
||||
<ion-router-outlet name="tab1"></ion-router-outlet>
|
||||
</ion-tab>
|
||||
|
||||
<ion-tab title="Tab 2" icon="heart">
|
||||
<ion-tab tabTitle="Tab 2" tabIcon="heart" href="/lazy-load-tabs/tabs/(tab2:camaro)">
|
||||
<ion-router-outlet name="tab2"></ion-router-outlet>
|
||||
</ion-tab>
|
||||
|
||||
<ion-tab title="Tab 3" icon="star">
|
||||
<ion-tab tabTitle="Tab 3" tabIcon="star" href="/lazy-load-tabs/tabs/(tab3:charger)">
|
||||
<ion-router-outlet name="tab3"></ion-router-outlet>
|
||||
</ion-tab>
|
||||
|
||||
|
Reference in New Issue
Block a user