Using knockout.js, how do I include a carriage return in the text that is bound to the text attribute of a paragraph <p>
element.
In my ViewModel I generated a string of text that is bound to the <p>
in the View. I want to include carriage returns in the string which the browser displays with the line breaks.
Including <br />
or Environment.NewLine
in the string does not seem to work.
You could also use spans to get your bindings and then the html will be as usual.
You can use the html binding.
JS:
View :
See fiddle
You need to set a css property in your element.
white-space: pre-wrap
Then the code works. with
\n