Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New line on alert message

Tags:

ionic2

ionic3

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.

like image 626
Dasonic Avatar asked Jan 28 '23 06:01

Dasonic


1 Answers

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

like image 53
Suraj Rao Avatar answered Feb 21 '23 08:02

Suraj Rao