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

后端 未结 1 1159
花落未央
花落未央 2021-01-04 01:51

I\'m using this code to display toasts on an AngularJS site. I need to know how to put a line break (
) into the body. When I use the options shown in

相关标签:
1条回答
  • 2021-01-04 02:58

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

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

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

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

    or

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

    Source

    0 讨论(0)
提交回复
热议问题