let errores = Object.values(this.errores)
let stringError = ""
for (let index = 0; index < errores.length; index++) {
stringError += errores[index] + "n"
}
return stringError
How can get a line break which basically returns a string?
- This is on angular ionic with an alert controller
- I’m putting this error on the message
I tried whit a br
but, I’m not getting a line break.
2
Answers
Hi i solved this by adding
on app.module.ts this:
setting innerHTMLTemplatesEnabled: true will enable to use IonicSafeString on IONIC 7, so when i return string will be like this:
To display line breaks in an Ionic alert controller, you need to use HTML tags and set the message property to interpret the message as HTML. You can achieve this by using the innerHTML property in the message attribute of the Alert Controller.
Here’s how you can do this:
Modify your code to use the
<br>
tag for line breaks:When creating the alert, use the message property to set the innerHTML:
In your global.scss or the relevant stylesheet, add the following CSS rule to enable innerHTML interpretation for the alert message:
This will allow you to display the error messages with proper line breaks in your Ionic alert controller.