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
Asked
Active
Viewed 1.1k times
23

FootsieNG
- 809
- 3
- 12
- 27
3 Answers
24
ng-hide
uses the same property that you're referring to, i.e. 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;
}

isherwood
- 58,414
- 16
- 114
- 157

Pooja Shah
- 485
- 2
- 10
16
I have got this working
ng-style="{visibility: notesOpened && 'visible' || 'hidden'}"

Himanth Kumar
- 316
- 2
- 13
3
You should try ng-class
instead so you can give the div a class which only do display:none

Fuzzyma
- 7,619
- 6
- 28
- 60
-
there is no such thing as `display: hidden`, only `display: none` and `visibility: hidden` – Hubert Grzeskowiak Nov 16 '16 at 15:27