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.
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.
Share Improve this question edited Aug 21, 2016 at 8:46 Itsik Mauyhas asked Aug 21, 2016 at 8:29 Itsik MauyhasItsik Mauyhas 4,00415 gold badges74 silver badges119 bronze badges 2-
it looks like your function receives a
text
argument and it's not being passed – AranS Commented Aug 21, 2016 at 8:41 - editing it, but I think it will not work. – Itsik Mauyhas Commented Aug 21, 2016 at 8:45
2 Answers
Reset to default 4Firs guess, {{}} is missed and it should be:
<textarea rows = "{{countRowsInText(response.simLog)}}" cols = "200" style = "overflow:hidden">{{response.simLog}}</textarea>
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>