How to apply ng-if (or other conditional) in multiple <td> elements while maintaining DRY
I want to display multiple <td> elements based on the same condition. I am currently doing this with several identical ng-if directives, as such:
<tbody> <tr> <td> Display unconditionally </td> <td> Same here... (imagine more columns) </td> ... <td ng-if='myCondition'> Display based on condition </td> <td ng-if='myCondition'> And the same </td> <td ng-if='myCondition'> for plenty of columns </td> </tr> </tbody> As long as this works, all repetitions cannot be overlooked. Any ideas on how I could do this?
+23
Kostas Rousis Mar 25 '15 at 9:41 2015-03-25 09:41
source share1 answer
Use ng-if-start and ng-if-end
<table> <tr> <td ng-if-start="false" >one</td> <td>two</td> <td ng-if-end >three</td></td> <td>foure</td> <td>five</td> </tr> </table> +38
squiroid Mar 25 '15 at 9:51 2015-03-25 09:51
source share