This might be simple, but as a newbie to JS/mobile app developing world, having a hard time to figure out how to display large text onto a ionic page with new lines.
I have contenseperated new line with \n
jsontext = ‘{“lyrics_en”: “Amazing grace! How sweet the sound \n That saved a wretch like me!”}’;
results = ;
song : any;
Ionic seems not to make use of the new line command included in your json string.
A simple solution would be to split the lyrics string via split() into an array. So you would push the array from split to song variable and push that array to results. In your HTML template, add an inner *ngFor to output the lines and wrap them with a div or br.
If you simply want linebreaks in there. With @gregg’s idea to split() the text, you could still use that function. Then you’d have 1 thing to split with, and not several differen’t variations of \r, \n etc.
Didn’t know that existed, that’s quite handy! Though I think it would vary on a case to case basis (or just preference), at least for me. In some cases I’d want the paragraphs instead News posts? Paragraphs. Chat messages? whitespace: pre-line.