title: Why auto focus directive does not work
body: <p>Auto focus directive is not working look at my code </p>
  
  <p>i think there is some problem</p>
  
  <pre><code>var app = angular.module('angularjs-starter', []);
  
  app.controller('MainCtrl', function($scope) {});
  app.directive('autoFocus', ['$timeout', function ($timeout) {
  return {
      restrict: 'AC',
      link: function (scope, element, attrs, ctrl) {
          setTimeout(function () {
              if ($(element)) {// if value is already filled 
                  if (attrs.focusNext) { // if next Field provided then put focus on next field
                      var target = angular.element('#' + attrs.focusNext);
                      target.focus();
                  }
                  else element.focus();
              }
              else element.focus(); //setting current value focus
          }, 600);
      }
  };
  }])
  </code></pre>