My current setup includes a textarea as shown below:
<textarea rows="3" maxlength="144" ng-maxlength="144" type="text"
name="testPost" id="testPost_{{item.id}}"
ng-init="focusText('testPost', item.id)"
ng-model="item.testPost">
</textarea>
Accompanied by the following function:
$scope.focusText = function (columnSelected, id){
if(columnSelected == "testPost"){
var textId = "testPost_" + id;
document.getElementById(textId).focus();
document.getElementById(textId).setSelectionRange(0,0);
}
}
The issue I'm facing is that document.getElementById(textId)
is showing up as null
since the function is executed before the textarea is fully loaded. How can I ensure that the function runs only after the textarea has been completely loaded?