简体   繁体   English

如何使用ng-hide隐藏div而不会闪烁

[英]how to make the div hidden without flicker using ng-hide

Am using ng-hide to hide a div. 我正在使用ng-hide隐藏div。 it display when dom loaded and hides after a milli second. 加载dom时显示,一毫秒后隐藏。

 <div class="container" ng-hide = "{{flag}}">

how to make the div hidden without flicker 如何使div隐藏而不闪烁

You can use ng-if - in this case if the result of your condition is false then there wouldn't be a div element at all in the DOM. 您可以使用ng-if在这种情况下,如果条件的结果为false则DOM中根本没有div元素。

ng-hide uses CSS (afaik) to hide the specific element but the element is still put inside the DOM. ng-hide使用CSS(afaik)隐藏特定元素,但该元素仍放置在DOM内。 The CSS is applied after the DOM rendering - that is why you see this "flickering" 在DOM渲染之后应用CSS-这就是为什么您看到此“闪烁”的原因

<div class="container" ng-hide="{{flag}}" ng-cloak>

默认情况下隐藏,直到您的DOM被编译为止

您还可以使用ng-show="{{flag}}"来根据标志显示div,如果flag为false,则不会显示div,否则会显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM