angular-notifier icon indicating copy to clipboard operation
angular-notifier copied to clipboard

How to display a message of multi lines?

Open wureka opened this issue 5 years ago • 4 comments

How to display a message of multi lines?

I have tried

this.notifier.notify('error', 'HELLO, World<br/>line2\nline3');

all don't work.

wureka avatar Feb 14 '20 05:02 wureka

By default, the notification title can only be a string. Otherwhise, we would have to circumvent the integrated Angular XSS protection.

You could, though, use a custom template to use custom HTML, such as line breaks. See:

  • Docs: https://github.com/dominique-mueller/angular-notifier#custom-templates
  • Example (in the demo project): https://github.com/dominique-mueller/angular-notifier/blob/develop/projects/angular-notifier-demo/src/app/app.component.ts#L63

itsdevdom avatar Mar 10 '21 22:03 itsdevdom

What if I'm using it as a global service, from where I do the notifier.show() instead from the component? Have I to pass the template from every component that use it? Or am I missing something?

Javrd avatar Jun 07 '21 10:06 Javrd

I'm using at the moment this workaround:

::ng-deep .notifier__notification-message {
  white-space: pre-line;
}

Javrd avatar Jun 07 '21 10:06 Javrd