Is there a way to ensure that AngularJS renders table columns correctly even before receiving the actual content for them?
I have been using ng-if
to display the content, as I need different elements based on the value returned from an API call. This is why I haven't used ng-bind, which might seem like a more appropriate solution.
<td ng-if="someArray.length > 0"><a ng-href="someLink">Yes</a></td>
<td ng-if="someArray.length == 0">No</td>
With this approach, the column in question does not appear at all when someArray
is uninitialized. I could include a check for undefined
in the second ng-if
, but I would prefer the column to remain empty until a value is received.
I am still relatively new to AngularJS and I believe there must be a best practice for handling this situation.