javascript - 在 AngularJS 中将换行符(换行符)放入 toastr 消息中?

标签 javascript angularjs toastr

我正在使用这个 code在 AngularJS 站点上显示 toast 。我需要知道如何将换行符 ( <br/> ) 放入正文中。当我使用此 question 中显示的选项时, toastr 在屏幕上呈现标签,而不是将其解释为 HTML。我怎样才能在 toast 中换行?

最佳答案

有两种方法可以在 toast 中允许一些 HTML 标记,包括换行符。

toaster-options 中包含 'body-output-type': 'trustedHtml':

<toaster-container toaster-options="{
    'closeButton': false,
    'debug': false,
    'position-class': 'toast-bottom-right',
    'onclick': null,
    'showDuration': '200',
    'hideDuration': '1000',
    'timeOut': '5000',
    'extendedTimeOut': '1000',
    'showEasing': 'swing',
    'hideEasing': 'linear',
    'showMethod': 'fadeIn',
    'hideMethod': 'fadeOut', 
    'body-output-type': 'trustedHtml'
}"></toaster-container>

或者在对 toaster.pop() 的调用中包含 'trustedHtml':

toaster.pop('success', 'Saved', 'Saved<br/>it!', 3000, 'trustedHtml');

toaster.pop({
    type: 'success',
    title: 'Saved',
    body: 'Saved<br/>it!',
    bodyOutputType: 'trustedHtml'
});

Source

关于javascript - 在 AngularJS 中将换行符(换行符)放入 toastr 消息中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31254459/

相关文章:

javascript - 如何让我的 Ionic Button 刷新所有 ionic View 。 (在大多数情况下最好只是重新评估一个 ng-switch)

angularjs - 如何在AngularJS中的同一个元素上嵌套两个指令?

twitter-bootstrap - 使 toastr 警报看起来像 Bootstrap 警报

javascript - 从 Toastr 追加

php - 如何在 Vue 3 中使用 Laravel toastr 包

javascript - 一次两个滑动图像

javascript - 为什么此选择列表不呈现基于 defaultValue 选择的正确项目

javascript - 如何检查用户是否在 AngularJS 路由器中经过身份验证?

javascript - javascript 的绑定(bind)方法似乎没有按预期工作

javascript - window.close 不关闭 HTA 应用程序中的窗口