John Wick John Wick -4 years ago 132
AngularJS Question

Trigger first element in ng-repeat

How can I trigger the first element in ng-repeat. This is my code so far. I want to trigger the ng-click event on load of the page. Thank you in advance.

<div class="row member-list">
<a class="list-group-item active" ng-repeat="connect in Connected" ng-click="getChat(connect.TokenId, connect.SessionId)">
<h4 class="list-group-item-heading"><strong ng-bind="connect.SupportId"></strong></h4>
<ul class="list-unstyled">
<li><strong>Token ID :<strong ng-bind="connect.TokenId"></strong> </li>
<li>
<strong>Session :</strong>
<span class="Connect" ng-bind="connect.SessionId"><div class="ConnectIcon"></div></span>
</li>
<li><strong ng-bind="connect.CreateTime">Chat Duration :</strong></li>
</ul>
</a>

</div>

Answer Source

You can do this,

   <a class="list-group-item active" ng-repeat="connect in Connected" ng-click="$first && getChat(connect.TokenId, connect.SessionId)">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download