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 the item is shown, without resorting to setTimeout(), or some such thing? Here's an example plunk of the issue: http://plnkr.co/edit/synSIP?p=preview
You can write a simple directive , dont need jquery :
yourApp.directive('focusme',function(){
return function(scope,elem,att){
elem.focus();
}
});
and You can use it like this :
<input type="text" focusme>
如果您希望输入在显示时自动聚焦,请使用html5 autofocus属性:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.