如何在每次調整窗口大小時從angular指令更新元素寬度?調整大小後更新ng樣式的寬度
現在它只綁定一次。
DIRECTIVE
function calculateGameWidth() {
scope.responsiveGameWidth = Math.floor((window.innerWidth - 22)/Math.floor((window.innerWidth - 22)/232)) - 6;
return scope.responsiveGameWidth;
}
calculateGameWidth();
//On resize
window.onresize = function() {
calculateGameWidth();
}
HTML
<li ng-style="{width: responsiveGameWidth+'px'}"></li>
預先感謝。
https://stackoverflow.com/questions/30561615/css-update-on-resize-with -angularjs重複? – sweaver2112
已經不是! :) –