AngularJs element.height()不是一个函数 [英] AngularJs element.height() not a function

查看:151
本文介绍了AngularJs element.height()不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使该会影响元素的宽度/高度指令。翻翻例子我已经看到了你可以参考相应的功能获得/设置宽度/高度。例如,在指令链接功能我尝试做:

I am trying to make a directive that would influence element width/height. Looking through examples I've saw that you can get/set width/height by referencing appropriate function. For example in link function of directive I try to do:

    function link(scope, element, attr) {
        var height = element.height();
    }

然而,在我的code我得到错误:element.height不是一个函数

However in my code I get "Error: element.height is not a function".

我缺少参考了一些angular.js模块/库或文档不是最新的?

Am I missing reference to some angular.js module/library or documentation is not up to date?

推荐答案

如果您不包括jQuery的角度替换其自己的小图书馆,jqLit​​e。 jqLit​​e没有为DOM元素的高度()函数​​,所以你要么需要编写自己的,或在项目中使用完整版本的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.

有限jqLit​​e API是这里

The limited jqLite api is here.

这篇关于AngularJs element.height()不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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