I'd like to use Angular directives to automatically build nice tables for 
me, and I'm having trouble.

I have a bunch of JS objects like this one:
{product: 'ProdA',
 colour: 'Black',
 team: 'U16B',
 count: 5}.

Here's what I want the table to look like:

Team | Product | Count
----------------------
U14B | ProdA   | 20
     |---------+------
     | ProdB   | 20
     |---------+------
     | ProdC   | 20
-----+---------+------
U14G | ProdA   | 19   
     |---------+------
     | ProdD   | 19   
...

Notice that "colour" wasn't in the table, and was aggregated over.

The problem is that I have at least four tables like this, and I'm thinking 
it would be worth my time to make a clean solution. I'm looking for a clean 
way of doing this, and I'm hoping Angular Directives can help. Here's an 
example of how I imagine it could work:

<table class="item_table"
  sort-rows
  aggregate-identical-rows-in-rightmost-column
  make-rowspans-for-identical-cells
  make-alternating-rows-different-colours>
<tr>
  <th>Team</th>
  <th>Product</th>
  <th>Count</th>
</tr>
<tr ng-repeat="row in all_data_rows">
  <td>row.team</td>
  <td>row.product</td>
  <td>row.count</td>
</tr>
</table>

The problem is that when any of the directives in the <table> tag run, the 
rows created by the <tr ng-repeat...> don't exist yet. From this mailing 
list I see that I could go to the innermost ng-repeat and call a directive 
that checks for $last at every level, but this seems sketchy and is a 
really weird place to put those directives.

Am I trying to use directives for things they aren't designed for? Is $last 
really a perfectly good solution, even if I have nested ng-repeats and I 
have to check for $last all the way out to the <table> tag? Does anyone 
have a good way of doing this angularly?

I know there are javascript approaches I could take, but once the contents 
of the cells get more complicated (e.g. buttons), those get messier. This 
solution just seems so pretty if it would only work. I'd appreciate any 
thoughts.

Thanks,
Bartholomew

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to