In a web application I use the Dialog of Angular Material. It contains just a textarea, initially empty. I want to auto-focus on textarea when the user open the modal dialog. How can I do? This is my code but it doesn't work. I've also made a directive, but it doesn't work yet.
Html of modal dialog:
<md-dialog-content>
    <div class="md-dialog-content">
       <md-input-container>
          <label>My textarea</label>            
            <textarea ng-model="myText" md-maxlength="5000" auto-focus></textarea>
       </md-input-container>
    </div>
</md-dialog-content>
Autofocus directive:
angular.module('app').directive("autoFocus", function($timeout) {
  return {
    restrict: 'AC',
    link: function(_scope, _element) {
        $timeout(function(){
            _element[0].focus();
        }, 0);
    }
  };
})
This is the config of the dialog in the controller:
 $mdDialog.show({
                    controller:texateaController,
                    templateUrl: 'texatea.html',
                    parent: angular.element(document.body),
                    targetEvent: event,
                    clickOutsideToClose: false
                    }
                })
 
    