title: Deleting the array with splice not working properly?
body: <p>When i click on button value will be push to another array. next i click on the same button the pushing item will be deleted.
  in my project pushing done  properly.but second time click on the same button first element in the array deleted not the selected one.</p>
  
  <p>this is my html code.</p>
  
  <pre><code>&lt;a  class="btn {{table.btnClass}} btn-success"  ng-click="getTable(table)" style="padding-left:1px"&gt;{{table.tablename}}&lt;/a&gt;
  </code></pre>
  
  <p>This is my controller code</p>
  
  <pre><code>$scope.tableArray=[]
  $scope.tableslist=[]
  $scope.getTable=function(table){
      table.btnClass = table.btnClass == "btn-danger" ? "btn-success" : "btn-danger"
      console.log(table)
      var exists=false;
      angular.forEach($scope.tableArray, function (list) {
          if ((list.tablename == table.tablename)) {
              console.log(list.tablename)
               console.log(table.tablename)
              exists=true;
              $scope.tableArray.splice(list._id,1)
              return false
          }
       });
    if(!exists){
    $scope.tableslist.push(table)
    $scope.tableArray=$scope.tableslist
    console.log($scope.tableArray)
     table.color="red"
      }
  }
  </code></pre>
  
  <p>please help me</p>