Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在angular中更改甜警报的文本属性?_Angular_Sweetalert_Sweetalert2 - Fatal编程技术网

如何在angular中更改甜警报的文本属性?

如何在angular中更改甜警报的文本属性?,angular,sweetalert,sweetalert2,Angular,Sweetalert,Sweetalert2,下面是我的函数&我得到的值作为参数 基于我需要在中显示自定义文本的值。下面是我的代码 buttonClicked(value) { console.log(value); swal({ title: 'Are you sure?', text: 'ssss', type: 'warning', showCancelButton: true, confirmButtonColor: '#DD6B55', con

下面是我的函数&我得到的值作为参数

基于我需要在中显示自定义文本的值。下面是我的代码

buttonClicked(value) {
    console.log(value);
    swal({
      title: 'Are you sure?',
      text: 'ssss',
      type: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#DD6B55',
      confirmButtonText: 'Delete',
      // closeOnConfirm: true
    }).then((result) => {
      if (result === true) {
      }
    }, function (dismiss) { });
  }

如果您使用的是sweetalert2,那么您的代码存在一些问题。sweetalert的“取消”按钮操作未按预期工作。您需要如下所示对其进行修改。您还可以将自定义文本的值存储在变量中,具体取决于从函数传递的值,如下所示

功能按钮勾选(值){
console.log(值);
var自定义文本;
如果(值=='First button'){
customText=“单击的第一个按钮”;
}
else if(值=='Second button'){
customText=“单击第二个按钮”;
}
游泳({
标题:“你确定吗?”,
文本:自定义文本,
键入:“警告”,
showCancelButton:true,
confirmButtonColor:“#DD6B55”,
confirmButtonText:“删除”,
})。然后((结果)=>{
if(result.value){
警报(“删除”);
}
如果(result.dismise==swal.DismissReason.cancel){
警报(“取消”);
}
});
}

第一个按钮

第二个按钮
检查我的答案