I've got a seemingly simple problem with no apparent (by reading the Angular JS docs) solution.
我有一个Angular JS指令,它根据其他DOM元素的高度进行一些计算,以定义DOM中容器的高度.
指令中也有类似的情况:
return function(scope, element, attrs) {
$('.main').height( $('.site-header').height() - $('.site-footer').height() );
}
问题是,当指令运行时,找不到$('site-header')
,返回一个空数组,而不是我需要的jQuery包装的DOM元素.
Is there a callback that I can use within my directive that only runs after the DOM has been loaded and I can access other DOM elements via the normal jQuery selector style queries?