Input autofocus attribute

后端 未结 10 1523
Happy的楠姐
Happy的楠姐 2020-11-30 04:47

I have places in my code where I have this:


I would like to be able to use it like

10条回答
  •  無奈伤痛
    2020-11-30 05:20

    Create a directive like this

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

提交回复
热议问题