Search code examples
javascriptangulartypescriptelementprimeng

How to break primeng confirmation box message to separate line?


Can anyone give me the suggestion to break the confirm box message.

I have tried this below code. but it's showing br tag as a string. Any other way to solve this?

this.confirmationService.confirm({
                    message: 'CoC updated successfully' + '</br>' + ' Do you want to close or continue working with this?',
                    icon: 'fa fa-question-circle',
                    header: 'Confirm Save',
                    accept: () => {
                       this.infomessage = [];
                        this.infomessage.push({ severity: 'success', summary: '', detail: Updated Successfully' });                    },
                    reject: () => {
                        this.router.navigate(['versions']);
                    }
                });

Solution

  • Yup, I got it by the following steps.

    Step 1

    We need move {{message}} to inside the <pre> tag in confirmdialog.metadata.json file. like,

    <span class=\"ui-confirmdialog-message\"><pre>{{message}}</pre></span>
    

    Step 2

    And we should add white-space: pre-line in this class .ui-confirmdialog-message. like,

    .ui-confirmdialog-message {
           white-space: pre-line;
    }
    

    Step 3

    Then if you add \n, then we can break the message. like, message : updated successfully \nDo you want to close or continue working with this


    I hope this answer will helps to someone