title: set focus to textarea in an angular directive
body: <p>I have a directive that implements in-place editing. In its <code>link</code> function I have a watch that is supposed to set focus on the text box when editing is switched on:</p>
  
  <pre><code>$scope.$watch('view.enabled', function(value) {
    if (value) {
      var element = $element.find('input') || $element.find('textarea');
      var input = element &amp;&amp; element[0];
      if (input) {
        $timeout(function() {
          input.focus()
        });
      }
    }
  });
  </code></pre>
  
  <p>the directive can instantiate either an <code>input</code> element, or a <code>textarea</code> depending on the parameters. The problem is that invoking <code>focus()</code> on the <code>textarea</code> element does not set focus to it. For <code>input</code> elements it does set the focus though.</p>
  
  <p>Here is plnkr. Please help.</p>
  
  <p><a href="http://plnkr.co/edit/743HUP?p=preview" rel="nofollow">Plunker Link</a></p>
  
  <p>EDIT: using <code>autofocus</code> attribute on the <code>textarea</code> in HTML makes it get the focus, but I still do not understand why I cannot do it programmatically.</p>