ng-show disturbing div layout - angularJS
Asked Answered
A

3

23

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

Alek answered 14/4, 2014 at 13:3 Comment(0)
C
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;
  }
Cardinalate answered 14/4, 2014 at 13:9 Comment(0)
C
16

I have got this working

ng-style="{visibility: notesOpened && 'visible' || 'hidden'}"

Calceiform answered 23/9, 2014 at 11:3 Comment(0)
G
3

You should try ng-class instead so you can give the div a class which only do display:none

Grovel answered 14/4, 2014 at 13:5 Comment(1)
there is no such thing as display: hidden, only display: none and visibility: hiddenCouple

© 2022 - 2024 — McMap. All rights reserved.