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

committed by
Manu MA

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