简体   繁体   English

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

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

I'm using this code to display toasts on an AngularJS site. 我正在使用此代码在AngularJS网站上显示祝酒词。 I need to know how to put a line break ( <br/> ) into the body. 我需要知道如何将换行符( <br/> )放入体内。 When I use the options shown in this question , toastr renders the tag on screen, rather than interpreting it as HTML. 当我使用此问题中显示的选项时,toastr会在屏幕上呈现标记,而不是将其解释为HTML。 How can I get a line break into a toast? 我怎样才能突破干杯?

There are two ways to allow some HTML tags, including line breaks, in a toast. 有两种方法可以在toast中允许一些HTML标记,包括换行符。

Include 'body-output-type': 'trustedHtml' in toaster-options : 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>

Or include 'trustedHtml' in a call to toaster.pop() : 或者在调用toaster.pop()包含'trustedHtml'

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

or 要么

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

Source 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM