<!DOCTYPE html> <html ng-app="myApp"> <head> <title>angularjs-focus</title> </head> <body> <input type="text" set-Focus=""> <script type="text/javascript" src="js/angular.min.js"></script> <script type="text/javascript"> var myApp = angular.module('myApp',[]); myApp.directive('setFocus', function(){ return function(scope, element){ element[0].focus(); }; }); </script> </body> </html>