feat(angular): integrate back-button with ng router

This commit is contained in:
Manu Mtz.-Almeida
2018-09-05 23:39:51 +02:00
parent 3b957a6a59
commit 1bcca01e1a
2 changed files with 10 additions and 3 deletions

View File

@ -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);