Canonical Method of Setting Focus


#1

I have quite a few places in my app where there are three of four text input fields that are likely to be visited sequentially.

At the moment, I’m using on the variations on the ng-enter directive to hide the keyboard with the Keyboard plugin when ENTER / GO is hit.

Ideally I’d also programatically set focus at this point the next in sequence (or perhaps move on to the next phase in the process if it’s the last field). I can see a few custom directives that allow focus to be dynamically changed by effectively watching a scope variable and calling setFocus() on the context element.

Is this still the recommended way to acheive this? I can see discussions going way back and referring to focus handling being folded into v1.1 of Angular, but as far as I can see this still isn’t part of the code.

Am I just misunderstanding something or is using a 3rd party / custom directive the recommended route?