Sweetalert2 - 动态更改显示的文本 - Angular2

时间:2018-02-05 08:29:44

标签: javascript angular sweetalert2

我异步获得响应后如何更改文本?

  var swText = "<h3>Importiranje kvota, molimo sačekajte...</h3>";
  swal({ html: swText });
  swal.showLoading();
  this.koloService.importExcelFileWithOdds(this.brojKola, fileList)
      .subscribe(
          data => { swText = "<h3>Importiranje završeno!</h3>"; swal.hideLoading(); },
          error => {  swText = "<h3>Importiranje završeno!</h3>"; swal.hideLoading(); });

另外,在从服务器获得响应后,如何隐藏进度警报? 导入数据时,进度警报如下所示: enter image description here

在我从服务器得到响应之后,进度警报不会隐藏,只有一个OK按钮会关闭警报 - 我希望它在我从服务器得到响应后立即关闭。 enter image description here

1 个答案:

答案 0 :(得分:0)

有各种各样的getter用于访问SweetAlert2的不同部分:https://sweetalert2.github.io/#methods

您正在寻找LambdaMetafactory或更好的swal.getContent()

swal.getTitle()
swal('After mignight I will turn into a pumpkin')
swal.showLoading()

// change the title after 2 seconds
setTimeout(() => {
  swal.getTitle().textContent = 'I am a pumpkin now!'
  swal.hideLoading()
}, 2000)

相关问题