代码之家  ›  专栏  ›  技术社区  ›  Niladri Banerjee - Uttarpara

Angular 5 ngx toastr不显示html消息

  •  1
  • Niladri Banerjee - Uttarpara  · 技术社区  · 7 年前

    我用的是角度5 . 我使用了以下代码来呈现HTML标记以及如下消息: Hi<b>Hello</b> 这是不可能的。

    this.toastr.warning("Hi<b>Hello</b>");
    

    另外,我使用了下面的代码,它没有控制台错误,也没有任何输出(弹出窗口):

    this.toastr.show("<font color=\"red\">Hi<b>Hello</b></red></font>",null,{
    disableTimeOut: true,
    tapToDismiss: false,
    closeButton: true,
    positionClass:'bottom-left',
    enableHtml:true
    });
    

    如何在ngx toastr中启用HTML,使消息看起来像: 你好 你好

    1 回复  |  直到 7 年前
        1
  •  9
  •   Sajeetharan    7 年前

    按照参数的顺序改变你的配置,

    this.toastr.show('<font color=\"red\">Hi<b>Hello</b></red></font>"',
               'title' , {
                        enableHtml: true,
                        closeButton: true,
                        timeOut: 10000
                    });
    

    STACKBLITZ DEMO

    推荐文章