user979331 user979331 - 3 months ago 29
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?


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

<div ng-class="user.cobuyer ? 'col-md-6' : 'col-md-12">