Skip to content

Commit

Permalink
fix(angular): back-button
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Apr 3, 2018
1 parent 685d5a1 commit 1f78390
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
8 changes: 7 additions & 1 deletion angular/src/directives/navigation/ion-back-button.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import { Directive, HostListener, Optional } from '@angular/core';
import { Directive, HostListener, Input, Optional } from '@angular/core';
import { IonRouterOutlet } from './ion-router-outlet';
import { Router } from '@angular/router';

@Directive({
selector: 'ion-back-button'
})
export class IonBackButton {

@Input() defaultHref: string;

constructor(
@Optional() private router: Router,
@Optional() private routerOutlet: IonRouterOutlet,
) {}

@HostListener('click')
onClick() {
if (this.routerOutlet && this.routerOutlet.canGoBack()) {
this.routerOutlet.pop();
} else if (this.router && this.defaultHref != null) {
this.router.navigateByUrl(this.defaultHref);
}
}
}
33 changes: 0 additions & 33 deletions angular/src/directives/navigation/router-transition.ts

This file was deleted.

0 comments on commit 1f78390

Please sign in to comment.