簡體   English   中英

將換行符(換行符)放入AngularJS中的toastr消息中?

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

我正在使用此代碼在AngularJS網站上顯示祝酒詞。 我需要知道如何將換行符( <br/> )放入體內。 當我使用此問題中顯示的選項時,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',
    text: 'Saved<br/>it!',
    bodyOutputType: 'trustedHtml'
});

資源

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM