mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
feat(angular): integrate back-button with ng router
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { Injectable, Optional } from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
import { NavigationExtras, Router, UrlTree } from '@angular/router';
|
||||
import { BackButtonEvent } from '@ionic/core';
|
||||
|
||||
export const enum NavIntent {
|
||||
Auto,
|
||||
@ -19,7 +20,11 @@ export class NavController {
|
||||
constructor(
|
||||
private location: Location,
|
||||
@Optional() private router?: Router
|
||||
) {}
|
||||
) {
|
||||
window && window.addEventListener('ionBackButton', (ev) => {
|
||||
(ev as BackButtonEvent).detail.register(0, () => this.goBack());
|
||||
});
|
||||
}
|
||||
|
||||
navigateForward(url: string | UrlTree | any[], animated?: boolean, extras?: NavigationExtras) {
|
||||
this.setIntent(NavIntent.Forward, animated);
|
||||
|
Reference in New Issue
Block a user