#A – replace new line with br
Solutions with custom filter or CSS style to provide propper text formating
by Krzysztof Safjanowski
HTML
<div ng-app='app'>
<div ng-controller='ctrl'>
<textarea ng-model="text" cols="30" rows="10"></textarea>
<br /> <pre>{{ text }}</pre>
<div style="white-space: pre;">{{ text }}</div>
<div ng-bind-html="text | nl2br"></div>
</div>
</div>
JavaScript
angular.module('app', []).
controller('ctrl', function ($scope) {
$scope.text = 'lorem ipsumm\ndolor sit amet';
}).filter('nl2br', function () {
return function (filtered) {
console.log('filtered:', filtered);
return filtered.replace('\n', '<br>');
};
});