简体   繁体   English

如何在AngularJs中的自定义指令上设置.focus()?

[英]How can I set .focus() on a custom directive in AngularJs?

Fairly new to javascript. javascript新手。 I was wondering with the following tag, besides having to manually put in Ids, is there a way to set .focus() to the container (custom directive)? 我想知道以下标记,除了必须手动输入Ids外,还有没有办法将.focus()设置为容器(自定义指令)? The custom directive is a container div that acts as a tile. custom指令是一个充当切片的容器div。

<tile class="ng-scope gridster-item" tilevalue="1" gridster-item="tile" row="0" col = "0" ng-repeat="tile in selectedTiles"> </tile>

You'll need a focus attribute directive. 您将需要一个focus属性指令。 eg 例如

<tile class="ng-scope gridster-item" focus-directive tilevalue="1" gridster-item="tile" row="0" col = "0" ng-repeat="tile in selectedTiles"></tile>

Here's a related question on SO 这是关于SO的一个相关问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AngularJS-如何为自定义指令设置CSS类? - AngularJS - how to set css class for the custom directive? 如何将焦点设置为&#39;editableCellTemplate&#39;中使用的自定义指令中的文本字段? - How to set focus to textfields in custom directive used inside 'editableCellTemplate'? 如何在不对ID进行硬编码的情况下获取有角度的自定义指令的焦点? - How can I grab focus of an angular custom directive without hardcoding an ID? 如何将AngularJS指令设置为stopPropagation? - How can I make an AngularJS directive to stopPropagation? 如何将其转换为AngularJs指令? - How can I turn this into an AngularJs Directive? 如何在Angularjs指令中删除货币? - How can I remove currency in an Angularjs directive? AngularJS:如何将一个指令编译为另一个指令? - AngularJS : How can I compile a directive as another directive? 如何在angularJS指令中捕获模糊或焦点事件 - How to catch blur or focus event in angularJS directive 在将模型设置为undefined时,如何避免自定义angularjs指令的“解析”验证错误? - How can I avoid “parse” validation error for custom angularjs directive when setting model to undefined? 单击按钮时如何在AngularJs中设置一个指令的值 - How can I in AngularJs set the value of one directive when an button is clicked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM