#AngularJS I'm having an issue with deleting rows from a table. Whenever I click the DELETE button on any row, it always deletes the first one instead of the clicked row. Can someone help me identify where I went wrong? Here's a snippet of the code:
<tr id="riga" ng-repeat='x in cars'>
<td class="dimensione">{{x.id}}</td>
<td class="dimensione">{{x.targaauto}}</td>
<td class="dimensione">{{x.datiintestatario}}</td>
<td class="dimensione">{{x.marca}}</td>
<td><button type="button" class='btn btn-danger btn' data-bs-toggle="modal" data-bs-target="#finestra"> elimina</button></td>
</tr>
<div class="modal fade " id="finestra">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Attenzione</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<h5 class="modal-body">Sei sicuro di voler eliminare questo record?</h5>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" ng-click='rimuovi($index)' data-bs- dismiss="modal">OK</button>
<button type="submit" class="btn btn-secondary" data-bs-dismiss="modal">ANNULLA</button>
</div>
</div>
</div>
</div>
</table>
</tbody>
<script src="bootstrap.js"></script>
</body>
</html>
Function RIMUOVI
$scope.rimuovi=function($index){
$scope.cars.splice($index, 1)
}