I want my table to conditionally render its row based on whether the value is null or not. The rows have different custom entries and labels, that's why I can't just use ng-repeat. Here's the code:
<table>
<thead>
</thead>
<tbody>
<tr ng-show = "{{data.entry_1}} !== null">
<td>Custom Label 1</td>
<td>{{data.entry_1}}</td>
</tr>
<tr ng-show = "{{data.entry_2}} !== null">
<td>Custom Label 2</td>
<td>{{data.entry_2}}</td>
</tr>
.
.
.
<tr ng-show = "{{data.entry_n}} !== null">
<td>Custom Label n</td>
<td>{{data.entry_n}}</td>
</tr>
</tbody>
</table>
However, it seems that this way is not right. It's either javascript (compiler) is complaining at {{}} in the ng-show or at '!== null' or maybe both. How to evaluate an angular expression (in {{}}) inside an ng- directive?
I know that I could also evaluate this instead in the js file, but since I don't want to add further scope variables (to make my code cleaner), I chose to evaluate if it is null in the ng-show directive. Could someone tell me how to do it?
Thanks.
{{data.entry_2 !== null}}Btw you can still use ng-repeat in tr and render the row conditionally if the custom entities have an index as given in your example. For example {{data['entry_' + ($index + 1)] !== null}} can make your code concise. But of course if the attributes have random names this approach won't work.ng-show = "false", chrome dev tools show another attributedisplay: none. If it's just<tr ng-show="{{data.entry_i !== null}}">still evaluates to true anddisplay: noneis gone, eventhough entry_i is not assigned any value in js file (the variable actually should not exist).{{}}.