Reputation: 3984
I am trying to set textarea
rows property to the numer of rows
in the text.
Here is the textarea
:
<textarea rows = "countRowsInText(response.simLog)" cols = "200" style = "overflow:hidden">{{response.simLog}}</textarea>
Ant the countRowsInText()
function:
$scope.countRowsInText = function(text){
var numerOfRowsInText = text.split(\/r\n|\r|\n).length; //rows number - 500
console.log(numerOfRowsInText); //row number
return numerOfRowsInText;
}
And it doesn't work, shows only 2 rows. Thanks.
Upvotes: 0
Views: 9029
Reputation: 235
in your controller u can use:
var txtArea = document.getElementById('ptest').value.split('\n');
$scope.lines = txtArea.length;
then you can use lines in text-area
<textarea rows = "{{lines}}" cols = "200" style = "overflow:hidden">{{response.simLog}}</textarea>
Upvotes: 1
Reputation: 1015
Firs guess, {{}} is missed and it should be:
<textarea rows = "{{countRowsInText(response.simLog)}}" cols = "200" style = "overflow:hidden">{{response.simLog}}</textarea>
Upvotes: 4