I'm trying to use AngularJS to create a table of a list of events. But each event has a type, and events of different types have drastically different contents, and some types also generate more than one row.
In a perfect world, I'd do this:
<tbody>
<ng-repeat="event in events">
<ng-switch on="event.type">
<ng-switch-when="type1">
<tr>
...
</tr>
<tr>
...
</tr>
</ng-switch-when>
<ng-switch-when="type2">
<tr>
...
</tr>
</ng-switch-when>
...
</ng-switch>
</ng-repeat>
</tbody>
but this won't work because most browsers will discard or relocate the ng tags to enforce that the tbody only contains trs.
The only solution I've seen to related problem (How to use ng-repeat without an html element) is to have multiple tbody elements; I'd prefer not to do that, but even if I do this, giving the tbody the ng-repeat and ng-switch attributes, I still have the problem that I can't wrap multiple trs in a single ng-switch-when.
Is there a way to do this in AngularJS, or is this impossible?
<my-tr>
directive inside a<table>
tag, it'll get shifted to the outside of the table. So I think I'd have to build a slew of directives for table, tbody, tr, th, and td. – Coppola