I need to display the text with the line breaks, this is the script
<script>
var app = angular.module('MyApp', []);
app.controller('Ctrl', function ($scope) {
console.log('Controller is executed');
$scope.btnClick = function () {
console.log($scope.desc);
}
$scope.ShowData = function () {
$scope.text = $scope.desc;
}
});
</script>
And this is the html code
<body ng-controller="Ctrl">
<form>
<textarea ng-model="desc" cols="105" rows="15"></textarea>
<button ng-click="btnClick()">Submit</button>
<button ng-click="ShowData()">Show</button>
</form>
<div ng-bind="text"></div>
You can wrap your asp label in a pre tag, and it will display with whatever line breaks are set from the code behind. Show activity on this post. You can also use <br/> where you want to break the text.
Press ALT+ENTER to insert the line break.
The <br> tag inserts a single line break. The <br> tag is useful for writing addresses or poems. The <br> tag is an empty tag which means that it has no end tag.
This character is commonly known as the 'Line Feed' or 'Newline Character'. CR (character : \r, Unicode : U+000D, ASCII : 13, hex : 0x0d) : This is simply the 'r' character.
Try render text inside <pre></pre>
tag instead of <div>
.
Or use style="white-space:pre-wrap;"
on your div.
Just add this to your styles, this works for me
white-space: pre-wrap
HTML
<p class="text-style">{{product?.description}}</p>
CSS
.text-style {
white-space: pre-wrap;
}
By this text in <textarea>
can be display as it's in there with spaces and line brakes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With