2

I have a collection of table column objects that I am iterating over using ng-repeat. I am building the table dynamically based on the columns the user wants to see.

Each TH tag calls a "sortable" directive like this...

<th sortable collection="myCollection" sortcolumn="sortcolname">Heading</th>

this is fine when the values for the custom attributes are hard-coded in (as above). But, in my code I am getting the values from the object in the collection like this....

<th ng-repeat="col in cols" sortable collection="{{col.collection}}" sortcolumn="{{col.sortcol}}">{{col.DisplayName}}</th>

This is not working. The values in the custom attributes (collection & sortcolumn) have not been rendered in time and the sortable directive is getting the variable names ({{col.collection}} && {{col.sortcol}}) and not the variable values.

How can I do this?

mikerennick
  • 385
  • 2
  • 15
  • I'm very new to angular but I know you can set the priority of a directive. As a guess you could try changing the priority of the collection and sortcolumn directives to get processed after ng-repeat? – daniellepelley Aug 07 '14 at 19:55
  • This did not seem to work -- I looked at this post http://stackoverflow.com/questions/19270392/what-is-priority-of-ng-repeat-directive-can-you-change-it and set it to 1001 and 999 and neither works. – mikerennick Aug 07 '14 at 20:04
  • 1
    try passing your values to `collection` and `sortcolumn` without using the {{}}, ex: `collection="col.collection"` – m.e.conroy Aug 07 '14 at 20:07
  • I think m.e.conroy has the answer :) – mikerennick Aug 07 '14 at 20:26

1 Answers1

2

It has been a while since I've done any Angular, but are you sure you need the double brackets in your collection and sortcolumn attributes? As in, does this work?

<th ng-repeat="col in cols" sortable collection="col.collection" sortcolumn="col.sortcol">{{col.DisplayName}}</th>