将换行符(换行符)放入AngularJS中的toastr消息中?

jay*_*cer 16 javascript angularjs toastr

我正在使用此代码在AngularJS网站上显示祝酒词.我需要知道如何将换行符(<br/>)放入正文中.当我使用此问题中显示的选项时,toastr会在屏幕上呈现标记,而不是将其解释为HTML.我怎样才能突破干杯?

jay*_*cer 22

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

包括'body-output-type': 'trustedHtml'toaster-options:

<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>
Run Code Online (Sandbox Code Playgroud)

或者包括'trustedHtml'致电toaster.pop():

toaster.pop('success', 'Saved', 'Saved<br/>it!', 3000, 'trustedHtml');
Run Code Online (Sandbox Code Playgroud)

要么

toaster.pop({
    type: 'success',
    title: 'Saved',
    text: 'Saved<br/>it!',
    bodyOutputType: 'trustedHtml'
});
Run Code Online (Sandbox Code Playgroud)

资源