如何使用angularjs实现文本框获取焦点

<!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>

 

posted @ 2016-01-30 14:05  魔豆  阅读(1213)  评论(0编辑  收藏  举报