This is unfortunately a limitation of HTML and DOM. Angular has DOM
based templates, meaning that a DOM tree is a template for the view.
Knockout uses string based templates which in all cases but this one
are an inferior choice.
The main issue with tables is not the lack of some kind <ng:repeat>
widget, but rather that you can't add foreign elmenets into the table
dom. If you do that, browser will strip them. tables and select html
elements are special in this way.
we are thinking about some solution to work around this issue, but
currently have nothing to offer except for restructuring your DOM so
that you have only one root element that needs to be iterated over.
/i
> --
> You received this message because you are subscribed to the Google Groups "angular" group.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to angular+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/angular?hl=en.
>
>
<tr ng:repeat="{linked} f in foo">
<td ng:bind="f.firstName"></td><td ng:bind="f.lastName"></td>
</tr>
<tr linked>
<td ng:bind="f.currentDept"></td><td ng:bind="f.dueDate"></td>
</tr>
The ng:repeat widget could check if the {attributeName} exist and then
merge the template with another DOM nodes, so that would result in:
<tr>
<td>Jason</td><td>Forester</td>
<td>1234</td><td>22/05/2011</td>
</tr>
in one repeat cycle. It does, however, look awkward a little, doesn't it?
Regards,
Witold Szczerba
<table>
<my:foreach expr="item in items">
<tr><td>{{item.name}}</td></tr>
<tr><td>{{item.value}}</td></tr>
</my:foreach>
</table>
because when the browser parses the html, we end up with DOM looking like:
<table>
<tbody>
<tr><td>{{item.name}}</td></tr>
<tr><td>{{item.value}}</td></tr>
</tbody>
</table>
notice that the my:foreach tag was stripped by the browser.
The ideas we have is to use directives as markers:
<table>
<tr ng:repeat="item in items"
ng:repeat-sequence-start><td>{{item.name}}</td></tr>
<tr ng:repeat-sequence-end><td>{{item.value}}</td></tr>
</table>
Or now I thought of another approach that uses comments to relay
instructions to angular:
<table>
<tbody>
<!-- ng:repeat expr="item in items" -->
<tr><td>{{item.name}}</td></tr>
<tr><td>{{item.value}}</td></tr>
<!-- ng:repeat -->
</tbody>
</table>
Note that I had to add tbody tags explicitly because otherwise the
first comment ended up outside of the tbody that is automatically
added by browsers and the other one was inside.
We need a bit more testing and exploration before we decide on the
final solution.
/i
/i
/i
Good point, I hadn't considered that, and it's a reasonably common user
case as well. In theory the "fixed" rows could be put into a separate
<tfoot> but that's not really addressing the problem.
as I said, this is not an easy problem to solve and make everybody happy. :-)