我如何获得在AngularJS控制器的电流范围的DOM元素? [英] How do i get current scope dom-element in AngularJS controller?

查看:86
本文介绍了我如何获得在AngularJS控制器的电流范围的DOM元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有outerItems的列表。内的各outerItem IHAVE innerItems的列表。他们是动态排序。

I have a list of outerItems. Inside each outerItem Ihave a list of innerItems. They are dynamically sorted.

当鼠标光标点innerItems之一,我必须展示正确的innerItem元素上面弹出窗口。

When mouse cursor points at one of innerItems, I have to show the popup window right above that innerItem element.

DIV弹出身体是的孩子,因为我不想为每个innerItems单独弹出。

Popup div is body's child, because I do not want to have a separate popup for each of innerItems.

我看到它的方式 - 在NG-鼠标悬停我打电话,设置左/顶部属性来我绝对定位的弹出功能。因此,对于每个innerItems我想打电话jQuery的.offset()方法,让我从一个页面的左上角左/前值。

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.

那么如何才能得到当前范围元素的jQuery对象?或者,如果我选择了错误的方式,请告诉我该怎么做。

So how can I get jQuery object of current scope element? Or, if I've chosen the wrong way, please tell me what to do.

推荐答案

明白了!

在控制器:

function innerItem($scope, $element){
    var jQueryInnerItem = $($element); 
}

就这么简单。

这篇关于我如何获得在AngularJS控制器的电流范围的DOM元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆