, but unfortunately does not work! Is it possible? //Displ...">

Is it possible to have a newline in an Ionic2 toast?

I tried both \ n and br / "> , but unfortunately does not work!

Is it possible?

//Displaying toast to welcome user! let user = this.currentUser(); //console.log(user); let toast = Toast.create({ message: 'Hi ' + user.email + '! <br/> Welcome to My App', duration: 5000, position: 'bottom' }); toast.onDismiss(() => { console.log('Dismissed toast'); }); this.nav.present(toast); 
+6
source share
2 answers

This is actually possible. You can do the following:

 .toast-message { white-space: pre; } 

and \n to break the line.

Note. Take a look at home.ts and style.css .

See working plunkr

+10
source

Although the @iWork solution works in many situations, if you have a close button in your toast, it will be pushed out of the screen.

So you can use this stylesheet:

 .toast-message { white-space: pre-line; } 

ps you need to use \n to break a line in your line

+5
source

All Articles