【发布时间】:2013-07-16 01:21:02
【问题描述】:
我有一个简单的AngularJS directive with a templateUrl。该指令用于工具提示。
- 目前我附加了一个隐藏元素。然而,该指令的使用非常频繁,因此 会发生数百个数据 DOM 绑定,并且页面会变慢到无法使用的程度。
- 我只想实际加载模板,并在鼠标悬停时附加元素。
Reading the angular docs, there doesn't seem to be any way of making a directive delay rendering。我错过了什么吗?
// Tooltip directive
return function(){
return {
templateUrl: 'someTemplate.html',
replace: false, // Append our tooltip, rather than replace the element's contents.
link: function (scope, element, attrs) {
$element.on({
mouseenter: function () {
// Would like to render, and set up bindings, here (my question)
},
mouseleave: function () {
// Destroy rendered element here (simple stuff, not my question)
}
});
}
}
}
【问题讨论】:
标签: angularjs angularjs-directive