Search code examples
angularjsangular-ng-if

How to use ng if else in one html tag to derive the condition


Can anyone help me solving the below issue, Currently I am using below code to display the values where i am using the two <td> tags derive the conditional values , Is there any way I can do kind of else in one <td> tag?

<td class="features" ng-if="OrderStatus.length>0">
<span ng-repeat="indi in ServiceDisconnects.Service">{{indi.serviceID}}<br></span>
</td>

<td class="features" ng-if="!OrderStatus.length>0">
<span ng-repeat="indi in ServiceDisconnects.Service">{{indi.productID}}<br></span>
</td>

Solution

  • Why dont you check it inside ng-repeat

    <td ng-repeat="indi in ServiceDisconnects.Service">
    <span ng-if="OrderStatus.length>0" >{{indi.serviceID}}<br></span>
    <span ng-if="!OrderStatus.length>0" >{{indi.serviceID}}<br></span>
    </td>