title: AngularJS textarea linebreak/newline conversion
body: <p>I have a textarea with content populated through ng-model:</p>
  
  <pre><code>&lt;textarea data-ng-model="messageBody"&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>messageBody needs to be stored in the database using newline characters (\n) instead of line breaks.  However, when I use regex to convert newline to linebreak and pass that to the model, angular escapes the HTML.  Is there a way to pass the HTML directly to the model or textarea without it being converted?  Or, is there a better way to convert between textarea line breaks and newline characters?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>On further inspection, this wasn't an angular problem.  We are populating the database (Postgres) using an SQL script.  Turns out the strings inserted into the database weren't escaped.  Since the strings contained a newline character, that means they were being inserted directly as text.  Then, line break handling from the front end seemed to be producing inconsistent results from what was initially populated.  Long story short - I escaped the initial database content to accommodate for the newline character, and everything works fine.</p>