Skip to content

Commit

Permalink
feat(angular): integrate back-button with ng router
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Sep 5, 2018
1 parent 3b957a6 commit 1bcca01
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion angular/src/providers/nav-controller.ts
@@ -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,
Expand All @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions core/package.json
Expand Up @@ -32,6 +32,7 @@
"@stencil/sass": "0.1.0",
"@stencil/utils": "latest",
"@types/jest": "^23.3.1",
"agadoo": "^1.0.0",
"autoprefixer": "^9.0.2",
"chromedriver": "^2.38.3",
"clean-css-cli": "^4.1.11",
Expand Down Expand Up @@ -77,8 +78,9 @@
"theme-builder:dev": "sd concurrent \"npm run theme-app-build -- --watch\" \"stencil build --dev --watch\" \"stencil-dev-server\" \"npm run theme-server\" ",
"theme-server": "node scripts/theme-builder/server.js",
"tsc": "./node_modules/.bin/tsc -p .",
"validate": "npm run lint && npm run test && npm run build",
"validate.ci": "npm run lint && npm run test && npm run build --max-workers 1 --debug"
"test.treeshake": "agadoo dist/collection/index.js",
"validate": "npm run test.treeshake && npm run lint && npm run test && npm run build",
"validate.ci": "npm run test.treeshake && npm run lint && npm run test && npm run build --max-workers 1 --debug"
},
"author": "Ionic Team",
"license": "MIT",
Expand Down

0 comments on commit 1bcca01

Please sign in to comment.