So I\'m trying to do something very simple and I\'m stuck. I have a String
variable and within that variable I Wanna set line break so certain part of the text
Here are two demonstrably working versions...
Solution One... if you want newlines to be respected in HTML... (works with the back-tick strings, or with 'My \ntitle'
...
document.getElementById('example').innerHTML = `My
title`;
h1 {
white-space: pre;
}
Angular Version:
{{title}}
Solution two... you want to use HTML...
document.getElementById('example').innerHTML = 'My
title';
Use ng-bind-html if you want to allow HTML during binding.