从NG-内重复调用一个angularjs属性指令 [英] calling an angularjs attribute directive from inside an ng-repeat
问题描述
我有我遍历使用NG-重复表列对象的集合。我建立了动态表根据用户希望看到的列。
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.
每个TH标签所谓的排序指令像这样...
Each TH tag calls a "sortable" directive like this...
<th sortable collection="myCollection" sortcolumn="sortcolname">Heading</th>
这是罚款时,自定义属性的值是硬codeD(如上)。但是,在我的code我越来越喜欢这个集合中从对象中的值....
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>
这是行不通的。在自定义属性的值(集合&安培; sortcolumn)的时间都没有被渲染和排序指令获取变量名称({{col.collection}}&放大器;&安培; {{col.sortcol}}),而不是变量的值。
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?
推荐答案
这已经有一段时间,因为我做了任何角度,但你确定你需要在你的收集和sortcolumn属性双括号?如,做这项工作?
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>
这篇关于从NG-内重复调用一个angularjs属性指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!