Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Routes - Can a Tab Keypress Initiate a Route?

I’m new to Angular (v5) and working with routes into Express (/api/my_route.js), in order to see if a input item value entered exists within my MongoDB collection.

The thing I’m not sure about and checked for a solution is that, I’m attempting to call this route to check the value in mongo when the user presses the tab key. When tab is pressed, it calls a function which in turn, was hoping would call my route.

Can you please let me know if a route can be called from a tab key press or should I be doing this another way as I’m still trying to get to grips with Angular?

From what I can see in my Express log, none of my console.log messages are appearing.

Thanks.

like image 672
tonyfat Avatar asked Feb 03 '26 07:02

tonyfat


1 Answers

You can always bind the tab keydown event, listen for it, and then use angular router to navigate to whichever route you want.

<input (keydown.tab)="..."> //use the tab keydown event

In your controller

this.router.navigateByUrl(<ur route url>);
like image 199
ashfaq.p Avatar answered Feb 05 '26 20:02

ashfaq.p