AngularJs element.height() 不是函数 [英] AngularJs element.height() not a function
问题描述
我正在尝试制定一个会影响元素宽度/高度的指令.查看示例,我看到您可以通过引用适当的函数来获取/设置宽度/高度.例如在我尝试做的指令的链接功能中:
I am trying to make a directive that would influence element width/height. Looking through examples I've seen that you can get/set width/height by referencing appropriate function. For example in link function of the directive I try to do:
function link(scope, element, attr) {
var height = element.height();
}
但是,在我的代码中,我得到错误:element.height 不是函数".
However, in my code I get "Error: element.height is not a function".
我是否缺少对某些 angular.js 模块/库的引用或文档不是最新的?
Am I missing the reference to some angular.js module/library or documentation is not up to date?
推荐答案
如果你不包括 jQuery angular 替代它自己的较小的库,jqLite.jqLite 没有用于 DOM 元素的 height() 函数,因此您需要自己编写或在项目中使用完整版的 jQuery.
If you are not including jQuery angular substitutes its own smaller library, jqLite. jqLite does not have a height() function for DOM elements, so you will either need to write your own or use the full version of jQuery in your project.
有限的 jqLite api 这里.
The limited jqLite api is here.
这篇关于AngularJs element.height() 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!