Skip to content Skip to sidebar Skip to footer

Select Input Shown With Ng-show

I'd like to put the focus on an input after it's shown with ng-show. However, this requires a jquery call to be made after the $digest cycle. Does anyone know how to run code after

Solution 1:

You can write a simple directive , dont need jquery :

  yourApp.directive('focusme',function(){
   returnfunction(scope,elem,att){
      elem.focus();
   }
  });

and You can use it like this :

    <inputtype="text" focusme>

Solution 2:

If you want the input to be automatically focused when it is shown use the html5 autofocus attribute:

Post a Comment for "Select Input Shown With Ng-show"