Is there anyway to display new lines using an Alert in Ionic 3?
What should I replace '\n' with?
doFinalise() {
let confirm = this.alertCtrl.create({
title: 'Are you sure?',
message: 'Are these details correct?\n Price ($/L): \n KMs Done: \n Total Spent: \n Fuel Type: \n Date: ',
buttons: [ etc...
Eventually, the message will display variable just before the new line, but it is not required at this stage.
AlertController can parse HTML tags. So you can use <br/>
tag here.
let confirm = this.alertCtrl.create({
title: `Are you sure?`,
message: `Are these details correct?<br/> Price ($/L): <br/> KMs Done: <br\> Total Spent: <br\> Fuel Type: <br\> Date: `,
buttons: [ etc...
Or you can check my demo and try something with bullets or numbering.
let alert = this.alertCtrl.create({
title: 'Are you sure?',
message: `
Are these details correct?
<ul>
<li>Price ($/L):</li>
<li> KMs Done: </li>
<li>Total Spent: </li>
<li>Fuel Type:</li>
<li> Date: </li>
</ul>
`,
Source: this forum post by Mike Hartington of Ionic
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With