AngularJS - Remove \n from data
angularjs, javascript, json
Solution
You can use ngBindHtmlUnsafe directive, with `terms: '... <br/><br/>...'`
<p ng-bind-html-unsafe='data[0].terms'></p>
You can either send the html to the AngularJS, or send the string with `\n` and replace it with `<br/>` in AngularJS's controller. Either way should work. Hope it helps.
Demo
Problem
What is the best way to catch and format the "\n\n" inside of text being passed from the server to display line breaks? Fiddle is here: http://jsfiddle.net/nicktest2222/2vYBn/ ``` $scope.data = [{ terms: 'You agree to be bound be the terms of this site. \n\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus tempus lectus ac nunc malesuada, fringilla feugiat nibh rhoncus. Vestibulum adipiscing mi in est consectetur, vitae facilisis nulla tristique. Nam eu ante egestas, ultricies tellus eu, suscipit neque.\n\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum et ligula non tellus semper iaculis eget vestibulum metus. Nunc aliquam eros sit amet sapien posuere, ac hendrerit risus ultricies. Vivamus nec enim sed eros placerat pulvinar a quis dui.', agreed: false }]; ```