Omkar Dixit Omkar Dixit -4 years ago 99
HTML Question

How to show the text with Line Breaks

enter image description here

I need to display the text with the line breaks, this is the script

var app = angular.module('MyApp', []);
app.controller('Ctrl', function ($scope) {
console.log('Controller is executed');
$scope.btnClick = function () {
$scope.ShowData = function () {
$scope.text = $scope.desc;

And this is the html code

<body ng-controller="Ctrl">
<textarea ng-model="desc" cols="105" rows="15"></textarea>
<button ng-click="btnClick()">Submit</button>
<button ng-click="ShowData()">Show</button>
<div ng-bind="text"></div>

Answer Source

Try render text inside <pre></pre> tag instead of . Or use "style="white-space:pre-wrap;" on your div.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download