ng-show disturbing div layout - angularJS

2019-06-14 21:48发布

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

3条回答
够拽才男人
2楼-- · 2019-06-14 22:05

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;
  }
查看更多
淡お忘
3楼-- · 2019-06-14 22:10

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

查看更多
再贱就再见
4楼-- · 2019-06-14 22:23

I have got this working

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

查看更多
登录 后发表回答