I have an AngularJS application that returns a list of json objects, and I repeat these objects and put them in a table.
Each table element has a Delete button using the ng-click method:
<td><a ng-click="testButton()" class="btn btn-danger btn-mini">Delete</a></td>
I use ng-resource to delete an object - and that works fine.
However, I also want to hide (or delete) the line where the object is located, and the delete button after deleting it - preferably using jQuery .
Here is my destroy method:
$scope.destroyThing = function() { $scope.thing= this.thing; $scope.thing.$destroy(); $(this.thing).closest("tr").hide();
The method completely destroys the object - it just does not delete the line ... so I tried registering the returned object when I click the button:
$scope.testButton = function() { console.log(this); }
It seems to return an angular Scope object, but I cannot find a way to access any of the DOM elements to which it refers.
Here is a screenshot showing you the object returned by the testButton function, which is launched by the click of a button, of course:
How can I access the DOM elements associated with an angular object using jQuery?
EDIT
Here is the full row of the table:
<tr ng-repeat="franchise in franchises"> <td ng-model="franchiseName">{{franchise.franchise_name}}</td> <td ng-model="franchiseNumber">{{franchise.franchise_number}}</td> <td><a class="btn btn-mini">Edit</a></td> <td><a ng-click="destroyFranchise()" class="btn btn-danger btn-mini">Delete</a></td> </tr>