将换行符(换行符)放入AngularJS中的toastr消息中? [英] Put a line break (newline) into a toastr message in AngularJS?

查看:233
本文介绍了将换行符(换行符)放入AngularJS中的toastr消息中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using this 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 renders the tag on screen, rather than interpreting it as HTML. How can I get a line break into a toast?

推荐答案

有两种方法可以允许某些HTML标记,包括换行符,敬酒。

There are two ways to allow some HTML tags, including line breaks, in a toast.

中包含'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>

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

Or include 'trustedHtml' in a call to toaster.pop():

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

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

来源

这篇关于将换行符(换行符)放入AngularJS中的toastr消息中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆