calling an angularjs attribute directive from insi

2019-07-17 06:04发布

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?

1条回答
狗以群分
2楼-- · 2019-07-17 06:35

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>
查看更多
登录 后发表回答