user979331 user979331 - 1 year ago 90
AngularJS Question

AngularJS ng-if to determine which col-md to use

I have a line like this:

<div class="col-md-6" ng-if="user.cobuyer">

user.cobuyer is either true or false, if its false, I want the col-md-6 to be col-md-12, if its true it can be col-md-6

How would I do this?

Answer Source

Use ng-class with a ternary for this, don't use ng-if.

<div ng-class="user.cobuyer ? 'col-md-6' : 'col-md-12">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download