title: Trigger click on first element in list in angularjs
body: <p>I'm an angularjs newbie building my first app. I have a list of users that I can filter and sort:</p>
  
  <pre><code>&lt;button ng-click="order='lastname'; reverse=!reverse"&gt;Sort by name&lt;/button&gt;
  &lt;button ng-click="order='id'; reverse=!reverse"&gt;Sort by id&lt;/button&gt;
  &lt;input type="text" ng-model="filter.user"&gt;
    &lt;ul class="userlist" ng-class="{blur: currentUser}"&gt;
      &lt;li ng-repeat="user in users | orderBy:order:reverse | filter:filter.user"&gt;
        {{user.id}} / {{user.firstname}} {{user.lastname}}
        &lt;a href="#/user/{{user.id}}"&gt;Show details&lt;/a&gt;
        &lt;div ng-click="showDetails(user)"&gt;Show details in overlay&lt;/div&gt;
      &lt;/li&gt;
    &lt;/ul&gt;   
    &lt;div ng-show="details"&gt;
      &lt;div ng-click="details=!details"&gt;close&lt;/div&gt;
      {{user.custom}}
    &lt;/div&gt;
    &lt;div ng-show="currentUser" id="overlay"&gt;
      {{currentUser.firstname}} {{currentUser.lastname}} {{currentUser.custom}}
      &lt;div ng-click="closeOverlay()"&gt;close&lt;/div&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>I can click on a user to get his details. Now I want to realize the following scenario: When I press the enter key in the filter text input I want to show the details of the first <code>&lt;li /&gt;</code> in the list at the current time. So in jQuery I would bind a keypress event to the input which would check for the key code (13) and then would trigger: <code>$('li').eq(0).click()</code> which would call <code>showDetails()</code> on that particular user - easy.<br>
  How can I build such functionality with angular? I tried using the <code>ng-keypress</code> directive which lets me bind a function to a certain keypress but now I'm stuck because I don't know how to trigger the <code>showDetails()</code> function on the first element. Any help greatly appreciated!</p>