我使用這個指令:如何使角度指令不斷檢查元素的高度?
App
.directive('maxHeightBorder', function(){
return {
restrict: 'A',
link: function($scope, $el, $attr){
if($el.height() >= $attr.maxHeightBorder){
$el.css('box-shadow','0 0 5px 5px black');
}
}
}
});
與此元素:<ul class="list-group" id="events-list" max-height-border="250">
問題是:當我加載頁面,這個元素是空的,指令的if
語句失敗。加載之後,Angular填充這個元素的高度超過250px,但是這個指令不會被檢查,所以新的樣式從不應用。
你如何填充內容的元素?請在代碼中顯示更多的代碼 – subZero
ul裏面的trackedEvents'>裏面的ng-repeat ='trackedEvent' – Cystack