如何在AngularJS控制器中获取当前范围dom元素? [英] How do I get current scope dom-element in AngularJS controller?
问题描述
当鼠标光标指向innerItems之一时,我必须在该innerItem元素的正上方显示弹出窗口。
Popup div是body的小孩,因为我不想为每个innerItems单独弹出一个。
我看到的方式 - 在 ng-mouseover
我调用将左/右属性设置为我绝对定位的弹出窗口的函数。所以对于每个innerItems,我想调用jQuery .offset()
方法,它给出了页面左上角的左/右值。
那么如何获取当前范围元素的jQuery对象?或者,如果我选择错误的方式
在控制器中:
function innerItem($ scope,$ element){
var jQueryInnerItem = $($ element);
}
I have a list of outerItems. Inside each outerItem, I have a list of innerItems. They are dynamically sorted.
When mouse cursor points at one of innerItems, I have to show the popup window right above that innerItem element.
Popup div is body's child, because I do not want to have a separate popup for each of innerItems.
The way as I see it — on ng-mouseover
I call the function that sets left/top properties to my absolutely positioned popup. So for each of innerItems I'd like to call jQuery .offset()
method that gives me left/top values from the top-left corner of page.
So how can I get jQuery object of current scope element? Or, if I've chosen the wrong way
In controller:
function innerItem($scope, $element){
var jQueryInnerItem = $($element);
}
这篇关于如何在AngularJS控制器中获取当前范围dom元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!