I am currently utilizing angularJS for the development of a Single Page Application (SPA). My challenge lies in deleting an object from an array within my controller, particularly while using ng-repeat. Below is the relevant HTML snippet:
<div class="cat-button" ng-repeat="category in cats" category="category">
<button class=" close-button" ng-click="removeCat()">
<span class="glyphicon glyphicon-remove-sign" aria-hidden=true> </span> </button>{{category.name}}
</div>
Each object stored in my $scope.cats
array is displayed within a div, along with a button for deletion. While this setup functions properly, I am unsure how to utilize these buttons to delete their corresponding objects.
Upon clicking the button, the controller's function is triggered. However, I am struggling to identify the specific object that needs to be removed dynamically by the user.
Outlined below is the relevant code within my controller:
//Function to delete category
$scope.removeCat = function () {
//I understand that I need to use splice on the array, but how can I determine the object that requires deletion?
};