Last active
February 4, 2016 18:55
-
-
Save wesleycho/2b259ca5e06c316376ee to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@Directive({ | |
host: { | |
'(click)': 'goToRoute($event)', | |
'(keydown)': 'goToRoute($event)' | |
} | |
}) | |
class MyRouteHandler { | |
@Input() route; | |
constructor(private _router: Router) {} | |
goToRoute(evt: Event | KeyboardEvent) { | |
if (evt.type === 'click' || (evt.type === 'keydown' && evt.keyCode === 13) { | |
this._router.navigate([this.route]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment