I have an angular app. Inside one controller I have a field for answers that is hidden. When a button is clicked using ng-click, that field is shown. I want to focus the cursor in that field. I have tried using:
document.getElementById("answer").focus();
but this doesn't work. However, when an answer is submitted some code is run and then the document.getElementById("answer").focus();
works.
The original function that shows the field is:
$scope.startStream = function () {
$scope.showStream = true;
document.getElementById("answer").focus();
};
Why does it not focus the cursor?