I am using ng-show="!notesOpened"
to hide a div if the notesOpened variable is true. However when hidden it messes up layout. Is there a way to make ng-show act in the same way as the css property visibility:hidden
? so that all div elements around the div being hidden stay in the same place
ng-hide
uses the same property that you're referring to, ie display: none
.
If you need to achieve this, you need to use visibility: hidden;
For that you can use the ng-class
attribute.
eg: ng-class="{'vis-hidden': notesOpened==true}"
.vis-hidden{
visibility: hidden;
}
I have got this working
ng-style="{visibility: notesOpened && 'visible' || 'hidden'}"
你应该尝试使用ng-class
这样你就可以给div一个只display:none
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.