我是AngularJs上的新成员,我对如何呈现ng-class属性的角度有疑问。Angularjs ng class and resize event
与外部库工作(可视化,图表,...)我需要频繁触发resize事件:
window.dispatchEvent(new Event('resize'));
如: 图表,在全屏模式下改变其大小的容器中,里面的图表模态对话框...
当我做这样的事情在我的控制器:
$scope.fullscreen = true;
window.dispatchEvent(new Event('resize'));
console.log($('#mycontainer').height());
而且在我的模板:
<style>
#mycontainer {
width: 100px;
height: 100px;
background-color: orange;
color: white;
}
.fullscreen {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 99;
}
</style>
(...)
<div id="mycontainer" ng-class="{'fullscreen': fullscreen}">
content here
</div>
console.log打印旧尺寸而不应用全屏类。
有什么办法在控制器中呈现ng-class,或者强制应用类而不使用JQuery .addClass方法?
小提琴例如:https://jsfiddle.net/Garet/d9c7ux3j/2/
集纳克级=“{‘全屏’:真正}” – azad