title: Angularjs: How to pre-select input text field on page load?
body: <p>I have a simple text input field in my angular app which is prefilled with a default value. I want to preselect the text on page load.</p>
  
  <p>Input field:</p>
  
  <pre><code>&lt;input type="text" ng-model="city" class="form-control" select-on-load /&gt;
  </code></pre>
  
  <p>Directive:</p>
  
  <pre><code>weatherApp.directive('selectOnLoad', function () {
  // Linker function
  return function (scope, element, attrs) {
      element.bind('load', function () {
          this.select();
      });
  };
  </code></pre>
  
  <p>});</p>
  
  <p>But nothing happens.</p>