diff --git a/angular/src/directives/navigation/ion-back-button.ts b/angular/src/directives/navigation/ion-back-button.ts index 8b448099930..418da9da825 100644 --- a/angular/src/directives/navigation/ion-back-button.ts +++ b/angular/src/directives/navigation/ion-back-button.ts @@ -1,12 +1,16 @@ -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, ) {} @@ -14,6 +18,8 @@ export class IonBackButton { onClick() { if (this.routerOutlet && this.routerOutlet.canGoBack()) { this.routerOutlet.pop(); + } else if (this.router && this.defaultHref != null) { + this.router.navigateByUrl(this.defaultHref); } } } diff --git a/angular/src/directives/navigation/router-transition.ts b/angular/src/directives/navigation/router-transition.ts deleted file mode 100644 index 7ef3bfdcf77..00000000000 --- a/angular/src/directives/navigation/router-transition.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { ComponentRef } from '@angular/core'; - -export function runTransition(enteringRef: ComponentRef, leavingRef: ComponentRef): Promise { - const enteringElm = (enteringRef && enteringRef.location && enteringRef.location.nativeElement); - const leavingElm = (leavingRef && leavingRef.location && leavingRef.location.nativeElement); - - if (!enteringElm && !leavingElm) { - return Promise.resolve(); - } - - return tr(enteringElm, leavingElm); -} - - -function tr(enteringElm: HTMLElement, leavingElm: HTMLElement): Promise { - console.log('transition start'); - - return new Promise(resolve => { - - setTimeout(() => { - - if (enteringElm) { - enteringElm.classList.add('show-page'); - } - - if (leavingElm) { - leavingElm.classList.remove('show-page'); - } - - resolve(); - }, 750); - }); -}