【发布时间】:2014-11-01 04:43:07
【问题描述】:
我正在创建一个动态 Angular js 应用程序,其中我想使用一个文本框作为表格过滤器的搜索文本。这是我正在做的事情的预览:
截至目前,我的代码如下所示
<table>
<thead>
<tr class="filterrow">
<td data-ng-repeat="col in items.Properties">
<input id="{{col.DatabaseColumnName}}" type="text"
data-ng-model="search_{{col.DatabaseColumnName}}"/>
<!-- Above Here I want to dynamically assign the ng-model based on Databasecolumnname property-->
</td>
</tr>
<tr>
<th data-ng-repeat="col in items.Properties">{{col.ColumnTitle}}</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="content in items2.Contents | filter: search_{{col.DatabaseColumnName}}: search_{{col.DatabaseColumnName}}">
<td data-ng-repeat="col in items.Properties">
<a href="#">{{content[col.Databasecolumnname ]}}</a>
</td>
</tr>
</tbody>
</table>
我已经尝试过使用 $compile 的方法,但我无法实现它。有什么想法吗?谢谢!
编辑:Plnkr - plnkr.co/edit/5LaRYE?p=preview
【问题讨论】:
-
当你给我们的信息这么少的时候,这很难帮助你,你能用你的完整代码设置一个 jsFiddle 或 plnkr 吗?你能分享一下“项目”结构的片段吗?谢谢!
-
我已经在 PSL 的评论中分享了我的 plnkr 作为评论。已经解决了。还是谢谢!
标签: javascript angularjs filter angular-ngmodel