【问题标题】:Angular Function call inside toaster not working烤面包机内的角函数调用不起作用
【发布时间】:2022-08-20 02:18:30
【问题描述】:

请我想在烤面包机内调用一个函数。当我放置一个href链接时,它可以工作,但按钮没有。 当我将按钮放在烤面包机之外时,该功能称它工作。 谢谢。

 this.toastr.toastrConfig.enableHtml=true;
 this.toastr.info(\" <button type=\'button\' (click)=\'this.exportexcel()\'>click here</button> \");

  exportexcel(): void
    {
console.log(\'text\')
    }

我已经尝试过了,它在烤面包机内部也不起作用,但在外部起作用。

<a style=\'cursor: pointer\' (click)=\'this.exportexcel()\'> cloud_download</a>

    标签: angular click toastr


    【解决方案1】:

    单击内容上创建的按钮时,我不知道如何调用函数,但是您可以覆盖 toastr 属性。

    在这种情况下,我覆盖了“onclick”属性,因此当您单击警报中的任意位置(关闭按钮除外)时,我会调用一个函数:

    this.toastr.toastrConfig.enableHtml=true;
    this.toastr.info(
      '<button type="button"> Click at this alert </button>', // Content
      'Export excel', // Title
      { onclick: () => this.exportexcel() }, // Override properties
    );
    
    exportexcel(): void {
      console.log('text')
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-29
      • 1970-01-01
      • 1970-01-01
      • 2018-02-26
      相关资源
      最近更新 更多