I have the following code for selecting all text inside input field:
<input id="userName" class="form-control" type="text" name="enteredUserName" data-ng-show="vm.userNameDisplayed()" data-ng-model="vm.enteredUserName"> and method to select all text:
vm.userNameDisplayed = function() { var textArea = angular.element('#userName'); textArea.setSelectionRange(0, vm.enteredUserName.length) } but after calling this method nothing is selected.
ng-showexpects an expression that resolves to truthy/falsy. In your case, the functionuserNameDisplayedwill be called when the page is rendered. If there is no data at that time, it will not select anything.