title: AngularJS: Move to next form input element after successful validation
body: <p>I have written a custom directive for validation of my form fields. When certain criteria are met (i.e. it is dirty and valid), I want to set the focus automatically to the next input element. This is a requirement from my users, such that they can move through the forms most efficiently.</p>
  
  <p>The simplified directive looks like this:</p>
  
  <pre><code>directive('custom', ['$parse', function($parse) {
      return {
          restrict: 'A',
          require: ['ngModel', '^ngController'],
          link: function(scope, element, attrs, ctrls) {
             var model=ctrls[0], form=ctrls[1];
  
             scope.next = function(){
                  return model.$valid
              }
  
              scope.$watch(scope.next, function(newValue, oldValue){
                  if (newValue &amp;&amp; model.$dirty){
                      ???
                  }
              })
  </code></pre>
  
  <p>Now my question is: how can I identify 
  - the next input element (which is the next sibling) or possibly via the tabindex
  - and focus on it 
  without using Jquery?</p>
  
  <p>For me, it is currently not clear, how to get to the next input element from the available "scope" or "element" attributes without Jquery; and JQlite does nothave a "focus" method. Basically, I need a working substitute for ??? in my code.</p>
  
  <p>Any help is highly appreciated. Thanks
  Juergen</p>