title: Execute different Event on First and second click angular js
body: <p>I have a situation where i need to execute different event on first and second click on div.
  On first click div will be expanded and in second click it will be redirected to it's detail page. Div contains details of post.</p>
  
  <pre><code>  &lt;div ng-click="select(comment._id);"
       ng-dblclick="changeurl(user.username,data.type,comment._id)"
         enter ng-repeat="user in data.user"&gt; 
  </code></pre>
  
  <p>Till now i was expanding div on first click and then on double click i was redirecting it to it's detail page.</p>
  
  <p>what would be the best way to do it.</p>
  
  <p>right now my idea is to make a counter on ng-click and then execute event.
   can we execute it on the DOM End.</p>
  
  <pre><code> &lt;div ng-click="counter = counter + 1"  ng-repeat="user in data.user" ng-init="counter = 0" &gt; 
  </code></pre>
  
  <p>is there any other directive where i can execute <strong>select(comment._id)</strong>       <strong>changeurl(user.username,data.type,comment._id)</strong> conditionally or how can i call these functions conditionally ?</p>
  
  <p>Update:  on Diana advice here is updated status:</p>
  
  <p>Here i have no of div's coming from ng-repeat, here i have two type of layouts which are displayed according to data.</p>
  
  <pre><code>  &lt;div ng-repeat="data in comments"&gt;
      &lt;div ng-if="data.type=story"&gt;
       &lt;div ng-click="clickEvent($index,comment._id, user.username,data.type);" enter ng-repeat="user in data.user"&gt;
    //displaying data here
      &lt;/div&gt;
        &lt;/div&gt; 
        &lt;div ng-if="data.type=news"&gt;
         &lt;div ng-click="clickEvent($index,comment._id, user.username,data.type);" enter ng-repeat="user in data.user"&gt; 
         //displaying data here
         &lt;/div&gt;
        &lt;/div&gt;
     &lt;/div&gt; 
  
  
  
  $scope.secondClick = [];
  //scope data  
  myservice.data().then(function(response){
      $scope.comments = response.data; 
      for (i=0; i&lt; $scope.comments.length;i++){
       $scope.secondClick[i] = false; 
       }
     });
  
  
  
  $scope.clickEvent = function(index,id, userName, type){
  
  if(!$scope.secondClick[index]){
  
      // Execute first-click logic (call select function with the id).
      $scope.secondClick[index] = true;
  }
  else{
  
      // Execute second-click logic (call changeurl function with the id, userName, and type).
  
   }
  </code></pre>
  
  <p>}</p>
  
  <p>I tried providing index to function and manipulate them. Because of nested ng-repeat i am getting index '0'. .</p>