A
A
Alexander Wolf2013-09-03 16:26:26
JavaScript
Alexander Wolf, 2013-09-03 16:26:26

Focus on input after ngShow

Hello! Can you please tell me how to do .focus()on the input element after showing it with ngShow?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
EugeneOZ, 2013-09-03
@mannaro

create a directive that will do element.focus() if expression==true and pass the same expression to its attribute that is in the ng-show attribute.
For example,

<div ng-show="tab=='superheroes'">
  <input type="text" data-focus-me="tab=='superheroes'" ng-model="hero.name" />
</div>

See an example here: plnkr.co/edit/6kHuj0?p=preview

A
Anton, 2013-09-03
@sHinE

Here stackoverflow.com/questions/16393527/angular-event-for-ng-hide-and-ng-show there is an example of a directive that fires an event when an element is shown/hidden, can it be useful?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question