Focus on input after the ngShow

Hello! Please tell me how to make .focus() on input element after showing it via the ngShow?
October 3rd 19 at 04:07
2 answers
October 3rd 19 at 04:09
Solution
create a Directive that will do the element.focus() in the expression condition==true in its attribute give the same expression, which is in the attribute ng-show.
For example,
<div ng-show="tab=='superheroes'">
 <input type="text" data-focus-me="tab=='superheroes'" ng-model="hero.name">
</div>

See example here: plnkr.co/edit/6kHuj0?p=preview
Thanks, I had not thought of? - nico.Hodkiewicz0 commented on October 3rd 19 at 04:12
Decided not to complicate the new Directive (because it is only in 1 place) and have used setTimeout, setting the time to 0ms. - nico.Hodkiewicz0 commented on October 3rd 19 at 04:15
October 3rd 19 at 04:11
Here stackoverflow.com/questions/16393527/angular-event-for-ng-hide-and-ng-show there is an example of a Directive which creates an event when showing/hiding the element, it may be useful?
Thank you:) - nico.Hodkiewicz0 commented on October 3rd 19 at 04:14

Find more questions by tags AngularJavaScript