AngularJS/UI - Focus input in dialogs

angular-ui, angular-ui-bootstrap, angularjs

Solution

I used the standard `autofocus` attribute in my template, and declared a simple directive to make it work for elements that are created after page load (like dialogs in your case).

app.directive('autofocus', function () {
  return {
    restrict: 'A',
    link: function (scope, element) {
      element[0].focus();
    }
  };
});

Problem

Is there any way to set focus in input controls using AngularJS/Angular-UI ? I saw that Angular-UI has some Jq-UI=focus directive but I'm unable to get it to work. I have a few dialogs that I display using Angular-UI $dialog service and would really like the first input on each dialog to get focus once it's shown

Original source