我想獲得一個元素的高度,當鼠標懸停在一個按鈕上時會出現這個元素。角度ng顯示回調
示例代碼:
<div ng-mouseenter="mouseoverPopUp()" ng-mouseleave="showpop=false">menu</div>
<div class="popover" ng-show="showpop">{{content}}</div>
$scope.mouseoverPopUp = function($event){
$scope.showpop = true;
var height = angular.element(".popover").innerHeight();
};
的問題是有時元件的高度正在得到它時,會出現之前。無論如何,我可以運行的代碼只有ng-show
有顯示元素?我需要在看起來調整元素的位置後立即獲得高度。
只是一種猜測你嘗試看showpop而不是監聽鼠標懸停? –
@BorisCharpentier我怎麼看showpop?這意味着當變量變化時,元素已經出現了嗎? – user1995781
我會建議你爲此做一個指令.. – Ved