2014-11-08 103 views
0

我正在创建一个指令,用于监视其他div元素的尺寸。观察元素的实际尺寸

我有这样的代码:

link: function(scope, element, attrs) { 
     var win = angular.element($('#id')); 
     win.bind('resize', function(e) { 
     alert(win.height()); 
     }); 
    } 

元#ID具有宽度= 100%和高度= 100%。当我调整我的窗户时,并没有发生。 那么,我能做些什么来获得真正的win.height?

回答

0
win.bind('resize', function(event) { 
    var height; 

    height = event.currentTarget.clientHeight // with padding 
    // or .offsetHeight (contains the height with the padding, scroll bar, and the border) 

    alert(height); 
});