title: Apply autofocus on input inside ng-repeat
body: <p>I want to autofocus the first input inside <code>ngRepeat</code> when my page loads and when I add a new item to array the focus should go for the last item of the <code>ngRepeat</code> and so on, doesn't matter how many items I add.</p>
  
  <p>Here's my code actually:</p>
  
  <pre><code>&lt;div class="add-top" ng-show="showstep=='step2'" style="position:relative;width:100%;"&gt;
    &lt;form name="EmailForm" novalidate accessible-form autocomplete="off" ng-submit="checkDup() &amp;&amp;  EmailForm.$valid ? Add() :''"&gt;
      &lt;div class="white text-center "&gt;
        &lt;!-- &amp;&amp; (emailDel | filter:'':true).length == emailDel.length --&gt;
        &lt;div class=" bg-color-upload03 ticket-top"&gt;
          &lt;div class="col-md-12 " ng-init="emailDel=[1]"&gt;
            &lt;div class="newevent-nav01"&gt;
              Enter email ids&lt;/div&gt;
            &lt;div class="col-md-6 col-md-offset-3" ng-repeat="e in emailDel track by $index"&gt;
  
              &lt;input type="email" class="text-left" placeholder="Email ID" validate-email ng-model="emailDel[$index]" ng-init="emailDel[$index]=''" ng-required="emailDel.length==1" name="email_{{$index}}" id="email_{{$index}}"&gt;
  
              &lt;div class="col-md-2 col-md-offset-10 text-left" style="margin-top: -10px;" ng-show="(emailDel.length-1)==$index"&gt;
  
                &lt;img src="../../../path to + symbol-active icon" width="40%" ng-hide="(EmailForm.$valid &amp;&amp; emailDel[ds.emailDel.length-1] !='')" /&gt;
  
                &lt;img src="../../..path to +symbol gray icon" width="40%" class="cursor-poi" ng-click="(EmailForm.$valid &amp;&amp; emailDel[emailDel.length-1] !='') ? emailDel.push(emailDel.length+1) :''" ng-show="(EmailForm.$valid &amp;&amp; emailDel[emailDel.length-1] !='')" /&gt;
  
              &lt;/div&gt;
              &lt;div class="col-md-12"&gt;
                &lt;span class="error" ng-show="EmailForm['email_'+$index].$touched &amp;&amp; !EmailForm['email_'+$index].hasFocus"&gt;
                            &lt;span ng-show="EmailForm['email_'+$index].$error.required"&gt;
                            Required
                            &lt;/span&gt;
                &lt;span ng-show="EmailForm['email_'+$index].$error.email"&gt;
                            Invalid Email
                            &lt;/span&gt;
                &lt;span ng-show="emailDel[$index]!='' &amp;&amp; (emailDel | filter:emailDel[$index]:true).length&gt;1"&gt;
                                Duplicate Email
                            &lt;/span&gt;
                &lt;/span&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="col-md-4 col-md-offset-4"&gt;
            &lt;div class="col-md-10 col-md-offset-1"&gt;
              &lt;button type="submit" class="btn" ng-disabled="EmailForm.$invalid || (emailDel.length&gt;1 &amp;&amp; (emailDel | filter:'':true).length==emailDel.length)"&gt;Continue&lt;/button&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>