简体   繁体   English

基于布尔的角度开关外分度

[英]Angular switch Outer Div based on boolean

I am using Angular 1.4.7 and need to do the following 我正在使用Angular 1.4.7,需要执行以下操作

<div ng-if="varIsTrue">
<div ng-if="!(varIsTrue)" my-custom-directive>
  A lot of content
</div>

So basically, if the div is set only the proper div shows up. 因此,基本上,如果设置了div,则仅显示正确的div。 I tried do a few variations of this with ng-if and ng-show but I believe because how the browser renders the dom it is messing it up with the multiple divs, but that is the concept I am going for. 我尝试使用ng-if和ng-show对此进行一些变体,但我相信,因为浏览器如何渲染dom会使它与多个div混淆,但这就是我要的概念。 Does anyone know how I can accomplish this? 有人知道我该怎么做吗?

You cannot do this you should have 2 closing tags 您不能这样做,您应该有2个结束标签

<div ng-if="varIsTrue">
</div>
<div ng-if="!(varIsTrue)" my-custom-directive>
  A lot of content
</div>

or you will have to switch in my-custom-directive 否则您将不得不切换我的自定义指令

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

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