title: How in angular to set an input field focused using name, model or id?
body: <p>I have a form and want when cursor leaves field one(blur), it will check if data is the word "test". And if the data doesn't contain, it will go back ad make field 1 focused again. </p>
  
  <pre><code>&lt;form name='yourForm' novalidate ng-submit="save(yourForm)"&gt;
  
          &lt;label&gt;Field 1&lt;/label&gt;
          &lt;input type="email" name="first" ng-model="fname" ng-blur="displayData(fname)"&gt;
          &lt;br&gt;&lt;br&gt;
  
          &lt;label&gt;Field 2&lt;/label&gt;
          &lt;input type="text" name="last" ng-model="lname" ng-blur="displayData(lname)"&gt;
  
          &lt;button type="button"&gt;finish&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>So I cannot find a solution how to set the field focus using field name, id or maybe ng-model.</p>
  
  <p>I want to do something like this but in angular:</p>
  
  <pre><code>var inp = document.getElementsByTagName('INPUT')[1];
  inp.focus();
  </code></pre>
  
  <p>but don't know how to get input index or to get input name.</p>