简体   繁体   中英

Angular switch Outer Div based on boolean

I am using Angular 1.4.7 and need to do the following

<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. 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. Does anyone know how I can accomplish this?

You cannot do this you should have 2 closing tags

<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

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.

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