我想在ionic中执行弹出删除功能,但数据仅隐藏在ionic中,但仍可在数据库中使用。我使用状态0和1。用户单击特定的数据删除按钮,数据隐藏在离子中,状态从1更改为0。
api.php
//VIEW MEDICINE
public function pharmacy(){
$pharmacy = AddMedicine::where('status',1)->get();
$datamsg = response()->json (['pharmacy' => $pharmacy]);
return $datamsg->content();
}
//hide data medicine
public function deleteMed(Request $request)
{
$id = $request->id;
$proID = $request->id;
$medname = $request->medname;
$price = $request->price;
$stock = $request->stock;
$medno = $request->medno;
$ingredient = $request->ingredient;
$description = $request->description;
$addinfo = $request->addinfo;
$status = $request->status;
$user = AddMedicine::where('medno', $request->input('medno'))->count();
if($user!=0)
{
AddMedicine::where('id', $id)->update([ 'status'=>'0'
]);
$msg = "Data deleted";
$datamsg = response()->json([
'success' => $msg
]);
return $datamsg->content();
}
else{
echo'{"error":{"text":" Medicine does not exist"}}';
}
}
medicine.ts
//alert delete data
confirmdelete() {
let alert = this.alertCtrl.create({
title: 'Confirm Delete',
message: 'Do you confirm to delete?',
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
},
{
text: 'Yes',
handler: () => {
// this.authService.postData(this.userData,'deleteMed').then((result) => {
// this.responsedata = result;
// if(this.responsedata.success)
// {
// let loader = this.loadingCtrl.create({
// duration: 200
// });
// loader.present().then( () => this.navCtrl.pop() );
// }
// else
// {
// this.presentError(this.responsedata.error.text);
// console.log(this.responsedata.error);
// }
// },(err) =>{
// });
}
}
]
});
alert.present();
}
我尝试了注释部分,但它读取了当前错误。我应该改用布尔值吗? 我尝试过
myValue:Boolean=false;
hideMe=false;
但是我不知道如何将其应用于离子型。
我想知道如何删除/隐藏离子数据。因为在api.php上,我已经在邮递员中进行了测试,并成功了。