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

Put a line break (newline) into a toastr message in AngularJS?

我正在使用这个 code to display toasts on an AngularJS site. I need to know how to put a line break (<br/>) into the body. When I use the options shown in this question,toastr 在屏幕上呈现标签,而不是将其解释为 HTML。我怎样才能让一个换行符变成吐司?

有两种方法可以在 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