-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(routerDirection): refactors goBack
- Loading branch information
1 parent
d623b3b
commit 54d7a12
Showing
11 changed files
with
95 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Directive, HostListener, Input } from '@angular/core'; | ||
import { NavController, NavIntent } from '../../providers/nav-controller'; | ||
|
||
@Directive({ | ||
selector: '[routerDirection]', | ||
}) | ||
export class RouterDirection { | ||
|
||
@Input() routerDirection: string; | ||
|
||
constructor( | ||
private navCtrl: NavController, | ||
) {} | ||
|
||
@HostListener('click') | ||
onClick() { | ||
this.navCtrl.setIntent(textToIntent(this.routerDirection)); | ||
} | ||
} | ||
|
||
function textToIntent(direction: string) { | ||
switch (direction) { | ||
case 'forward': return NavIntent.Forward; | ||
case 'back': return NavIntent.Back; | ||
case 'root': return NavIntent.Root; | ||
default: return NavIntent.Auto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.