I have created a database which has several tables such as questions,answers etc. And I have created a view page and display the data from database. Also I have created a controller for this view. I have given a delete button at the end of every record in my view. How can I delete a record on this delete button click
My view
<div class="container" ng-controller="questionEditCtrl">
<form class="form-horizontal" role="form" name='quizEdit' ng-submit="submit(data)">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Questions</th>
<th>Answer 1</th>
<th>Answer 2</th>
<th>Answer 3</th>
<th>Answer 4</th>
<th>Answer 5</th>
<th>Correct Answer</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
foreach ($quizes as $q) {
?>
<tr>
<td ng-model="data.quesID"><?php echo $q['question_id']; ?></td>
<td ng-model="data.ques"><?php echo $q['question']; ?></td>
<td ng-model="data.ans0"><?php
if (isset($q['answers'][0])) {
echo $q['answers'][0];
}
?></td>
<td ng-model="data.ans1"><?php
if (isset($q['answers'][1])) {
echo $q['answers'][1];
}
?></td>
<td ng-model="data.ans2"><?php
if (isset($q['answers'][2])) {
echo $q['answers'][2];
}
?></td>
<td ng-model="data.ans3"><?php
if (isset($q['answers'][3])) {
echo $q['answers'][3];
}
?></td>
<td ng-model="data.ans4"><?php
if (isset($q['answers'][4])) {
echo $q['answers'][4];
}
?></td>
<td ng-model="data.corr_ans"><?php
if (isset($q['correctAnswer'])) {
echo $q['correctAnswer'];
}
?></td>
<td><a href="">Edit</a> / <a href="" ng-click="delete()">Delete</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</form>
</div>
controller
;
(function () {
'use strict';
angular.module('app', []).controller('questionEditCtrl', ['$scope', '$timeout', '$http', function ($scope, $timeout, $http) {
$scope.delete = function () {
if (confirm("Are you sure you want to delete this record?")) {
// todo code for deletion
}
};
}]);
})();