AngularJS Live Example

HTML

<!-- AngularJS Example Code: -->

<script>
angular.directive('my:focus', function(){
  return function(element){
    element[0].focus();
  };
});
</script>
<div>
  Your name: <input type="text" ng:model="name" my:focus=""/>
</div>

CSS

.ng-invalid { border: 1px solid red; } 
body { font-family: Arial,Helvetica,sans-serif; }
body, td, th { font-size: 14px; margin: 0; }
table { border-collapse: separate; border-spacing: 2px; display: table; margin-bottom: 0; margin-top: 0; -moz-box-sizing: border-box; text-indent: 0; }
a:link, a:visited, a:hover { color: #5D6DB6; text-decoration: none; }
.error { color: red; }