0
我有一个指令,观察具有动态高度的元素的clientHeight,并将范围变量设置为该值,但我无法弄清楚如何进行单元测试。我在单元测试中所做的所有事情,clientHeight总是返回0.我已经尝试了许多不同的解决方案,我在这里阅读了类似的问题,但都没有成功。单元测试使用clientHeight的指令
这里是指令:
return {
link: function (scope, element, attrs) {
scope.$watch(function() { return element[0].clientHeight; },
function(newValue, oldValue) {
if (newValue !== oldValue) {
scope.$parent.headerHeight = newValue;
}
}, true);
}
};