Hey guys I want to delete item by id in an AngularJS function. How can I get id from delete button?
<table data-ng-app="myApp" data-ng-controller="myController">
<tbody>
<tr>
<th>ID</th>
<th>Name</th>
<th>School</th>
<th>Gender</th>
<th>Email</th>
<th>Update</th>
<th>Delete</th>
</tr>
<tr data-ng-repeat="student in students">
<td>{{student.id}}</td>
<td>{{student.name}}</td>
<td>{{student.school}}</td>
<td>{{student.gender}}</td>
<td>{{student.email}}</td>
<td><a href="#" id="tagaUpdate" >Update</a></td>
<td><a href="#" id="tagaDelete" data-ng-click="deleteItem({{student.id}})">Delete</a></td>
</tr>
</tbody>
</table>
Controller:
var myApp = angular.module('myApp', []);
myApp.controller("myController", function ($scope) {
$scope.deleteItem = function (id) {
alert(id);//it doesn't show alert here
};
});
I think the problem is here data-ng-click="deleteItem({{student.id}})". But when I check it shows me value data-ng-click="deleteItem(5).