0

I was able to implement auto-focus when you click a button taking you to the modal. Due to the following code:

AngularJS:

app.directive('autoFocus', function($timeout) {
    return {
        restrict: 'AC',
        link: function(_scope, _element) {
            $timeout(function(){
                _element[0].focus();
            }, 0);
        }
    };
});

HTML:

<input type="text" auto-focus>

However when applying the same logic to input boxes that are available after clicking on a button and going to a separate page, it doesn't seem to work. Has anyone encountered this before or experienced the same issue?

1 Answers1

0

I have used the built in autofocus like this

<input ... autofocus="{{$index==0}}"/>

Have you tried that? No custom directive.

solbs
  • 940
  • 3
  • 15
  • 29