I want delete when click in button , but my code not work . Here is my code html
<tr class="row" ng-repeat="data in vm.mydata >
<td class="col-md-1"> <span>{{data.masp}}</span></td>
<td class="col-md-1"> <span>{{data.hangsx}}</span></td>
</tr>
<i class="fa fa-trash-o fa-2x" aria-hidden="true" ng-click="vm.delete(data.masp)"></i>
angular
function dsController($http){
var vm =this;
$http.get('/project/app/server/data/data.php')
.then(onSuccess);
function onSuccess(response){
vm.mydata = response.data.records;
}
vm.delete = function(value){
$http({
method:'POST',
url:'/project/app/server/action/xoa.php',
data:({value:value}),
headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(onSuccess,onError);
function onSuccess(){
$http.get('/project/app/server/data/data.php')
.then(function(data){
vm.mydata = data.data.records;
})
}
and here is php code : xoa.php
//connect db
if(!empty($_POST['value'])){
$masp = $_POST['value'];
$sql = "DELETE FROM sanpham WHERE masp= '$masp'";
$result = mysqli_query($conn,$sql);
if($result){
echo 'OK';
} data.php
$rows = array();
if($result){
while($r = mysqli_fetch_assoc($result)) {
$rows[] = $r;
}
print '{"records":' .json_encode($rows) ."}";
Where is my wrong . Pls help me