我試圖達到類似全屏模式功能的東西:使用按鈕來觸發全屏模式,然後再返回一個按鈕。什麼時候ng-class結束表達式評估並應用這個類?
主題:
<div ng-class="{full: !presentationMode}">
<div id="child-div>content</div> //div has 100% height
</div>
觸發: <button ng-click="present()">Click me!</button>
和Controller我:
$scope.present =() => {
$scope.presentationMode = !$scope.presentationMode;
var myDiv = angular.element('#container');
// when $scope.presentationMode is true
// myDiv.height() is not the height set by the "full" class, but it is always reversed (the previous value)
// It !sometimes! work if I use $timeout.
}
我應該如何處理這種情況?
這裏有一個小提琴:https://jsfiddle.net/U3pVM/29641/
沒有幫助。不要緊,如果類名不包含破折號! – cristifilip