mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00

committed by
Manu MA

parent
a9247ce0e9
commit
509cfd54aa
@ -44,24 +44,35 @@
|
|||||||
"css/"
|
"css/"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ionic/core": "4.0.0-beta.17"
|
"@ionic/core": "4.0.0-beta.17",
|
||||||
|
"tslib": "^1.9.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular-devkit/core": "^7.0.3",
|
"@angular-devkit/core": "^7.1.2",
|
||||||
"@angular-devkit/schematics": "^7.0.3"
|
"@angular-devkit/schematics": "^7.1.2",
|
||||||
|
"@angular/core": "^7.1.2",
|
||||||
|
"@angular/common": "^7.1.2",
|
||||||
|
"@angular/forms": "^7.1.2",
|
||||||
|
"@angular/router": "~7.1.2",
|
||||||
|
"@angular/compiler": "^7.1.2",
|
||||||
|
"@angular/compiler-cli": "^7.1.2",
|
||||||
|
"@angular/platform-browser": "^7.1.2",
|
||||||
|
"@angular/platform-browser-dynamic": "^7.1.2",
|
||||||
|
"rxjs": ">=6.2.0",
|
||||||
|
"zone.js": "^0.8.26"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/core": "^7.0.3",
|
"@angular-devkit/core": "^7.1.2",
|
||||||
"@angular-devkit/schematics": "^7.0.3",
|
"@angular-devkit/schematics": "^7.1.2",
|
||||||
|
"@angular/core": "^7.1.2",
|
||||||
|
"@angular/common": "^7.1.2",
|
||||||
|
"@angular/forms": "^7.1.2",
|
||||||
|
"@angular/router": "^7.1.2",
|
||||||
|
"@angular/compiler": "^7.1.2",
|
||||||
|
"@angular/compiler-cli": "^7.1.2",
|
||||||
|
"@angular/platform-browser": "^7.1.2",
|
||||||
|
"@angular/platform-browser-dynamic": "^7.1.2",
|
||||||
"@types/node": "~10.12.0",
|
"@types/node": "~10.12.0",
|
||||||
"@angular/common": "^7.0.3",
|
|
||||||
"@angular/compiler": "^7.0.3",
|
|
||||||
"@angular/compiler-cli": "^7.0.3",
|
|
||||||
"@angular/core": "^7.0.3",
|
|
||||||
"@angular/forms": "^7.0.3",
|
|
||||||
"@angular/platform-browser": "^7.0.3",
|
|
||||||
"@angular/platform-browser-dynamic": "^7.0.3",
|
|
||||||
"@angular/router": "^7.0.3",
|
|
||||||
"fs-extra": "^7.0.0",
|
"fs-extra": "^7.0.0",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"rxjs": "^6.2.0",
|
"rxjs": "^6.2.0",
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Directive, ElementRef, HostListener, Input, Optional } from '@angular/core';
|
import { Directive, ElementRef, HostListener, Input, Optional } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { NavController } from '../../providers/nav-controller';
|
import { NavController } from '../../providers/nav-controller';
|
||||||
import { IonRouterOutlet } from './ion-router-outlet';
|
import { IonRouterOutlet } from './ion-router-outlet';
|
||||||
|
|
||||||
@ -17,7 +16,6 @@ export class IonBackButtonDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Optional() private router: Router,
|
|
||||||
@Optional() private routerOutlet: IonRouterOutlet,
|
@Optional() private routerOutlet: IonRouterOutlet,
|
||||||
private navCtrl: NavController,
|
private navCtrl: NavController,
|
||||||
private elementRef: ElementRef,
|
private elementRef: ElementRef,
|
||||||
@ -28,7 +26,7 @@ export class IonBackButtonDelegate {
|
|||||||
if (this.routerOutlet && this.routerOutlet.canGoBack()) {
|
if (this.routerOutlet && this.routerOutlet.canGoBack()) {
|
||||||
this.routerOutlet.pop();
|
this.routerOutlet.pop();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
} else if (this.router && this.defaultHref != null) {
|
} else if (this.defaultHref != null) {
|
||||||
this.navCtrl.navigateBack(this.defaultHref);
|
this.navCtrl.navigateBack(this.defaultHref);
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ export class RouterLinkDelegate {
|
|||||||
@Input() routerDirection: NavDirection = 'forward';
|
@Input() routerDirection: NavDirection = 'forward';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
|
||||||
private locationStrategy: LocationStrategy,
|
private locationStrategy: LocationStrategy,
|
||||||
private navCtrl: NavController,
|
private navCtrl: NavController,
|
||||||
private elementRef: ElementRef,
|
private elementRef: ElementRef,
|
||||||
|
private router: Router,
|
||||||
@Optional() private routerLink?: RouterLink,
|
@Optional() private routerLink?: RouterLink,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable, Optional } from '@angular/core';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { NavigationExtras, NavigationStart, Router, UrlTree } from '@angular/router';
|
import { NavigationExtras, NavigationStart, Router, UrlTree } from '@angular/router';
|
||||||
import { Platform } from './platform';
|
import { Platform } from './platform';
|
||||||
@ -16,11 +16,12 @@ export class NavController {
|
|||||||
private lastNavId = -1;
|
private lastNavId = -1;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
platform: Platform,
|
||||||
private location: Location,
|
private location: Location,
|
||||||
private router: Router,
|
@Optional() private router?: Router,
|
||||||
platform: Platform
|
|
||||||
) {
|
) {
|
||||||
// Subscribe to router events to detect direction
|
// Subscribe to router events to detect direction
|
||||||
|
if (router) {
|
||||||
router.events.subscribe(ev => {
|
router.events.subscribe(ev => {
|
||||||
if (ev instanceof NavigationStart) {
|
if (ev instanceof NavigationStart) {
|
||||||
const id = (ev.restoredState) ? ev.restoredState.navigationId : ev.id;
|
const id = (ev.restoredState) ? ev.restoredState.navigationId : ev.id;
|
||||||
@ -29,6 +30,7 @@ export class NavController {
|
|||||||
this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;
|
this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Subscribe to backButton events
|
// Subscribe to backButton events
|
||||||
platform.backButton.subscribeWithPriority(0, () => this.goBack());
|
platform.backButton.subscribeWithPriority(0, () => this.goBack());
|
||||||
@ -37,9 +39,9 @@ export class NavController {
|
|||||||
navigateForward(url: string | UrlTree | any[], animated?: boolean, extras?: NavigationExtras) {
|
navigateForward(url: string | UrlTree | any[], animated?: boolean, extras?: NavigationExtras) {
|
||||||
this.setDirection('forward', animated);
|
this.setDirection('forward', animated);
|
||||||
if (Array.isArray(url)) {
|
if (Array.isArray(url)) {
|
||||||
return this.router.navigate(url, extras);
|
return this.router!.navigate(url, extras);
|
||||||
} else {
|
} else {
|
||||||
return this.router.navigateByUrl(url, extras);
|
return this.router!.navigateByUrl(url, extras);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,18 +49,18 @@ export class NavController {
|
|||||||
this.setDirection('back', animated);
|
this.setDirection('back', animated);
|
||||||
// extras = { replaceUrl: true, ...extras };
|
// extras = { replaceUrl: true, ...extras };
|
||||||
if (Array.isArray(url)) {
|
if (Array.isArray(url)) {
|
||||||
return this.router.navigate(url, extras);
|
return this.router!.navigate(url, extras);
|
||||||
} else {
|
} else {
|
||||||
return this.router.navigateByUrl(url, extras);
|
return this.router!.navigateByUrl(url, extras);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateRoot(url: string | UrlTree | any[], animated?: boolean, extras?: NavigationExtras) {
|
navigateRoot(url: string | UrlTree | any[], animated?: boolean, extras?: NavigationExtras) {
|
||||||
this.setDirection('root', animated);
|
this.setDirection('root', animated);
|
||||||
if (Array.isArray(url)) {
|
if (Array.isArray(url)) {
|
||||||
return this.router.navigate(url, extras);
|
return this.router!.navigate(url, extras);
|
||||||
} else {
|
} else {
|
||||||
return this.router.navigateByUrl(url, extras);
|
return this.router!.navigateByUrl(url, extras);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user