本文介绍了AngularJS-未知提供程序:groupByFilterProvider<-groupByFilter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个对象数组.我需要按一个字段对数据进行分组,并将结果显示在HTML表格中.
I have a array of object. I need to group the data by one field and show the result in an HTML table.
输入:
[
{
id: "559e2bbc9a496034557d6d84",
text: "Data Sources",
topParentId: "559e2bbc9a496034557d6d84",
topParentText: "Data Sources"
},
{
id: "559e2bbc9a496034557d6d83",
text: "Applications",
topParentId: "559e2bbc9a496034557d6d83",
topParentText: "Applications"
},
{
id: "559e2bbc9a496034557d6d82",
text: "Analytics",
topParentId: "559e2bbc9a496034557d6d83",
topParentText: "Applications"
}
]
由此,我需要创建一个这样的HTML表(按topParentId对数据进行分组):
Group | Tags
Data Sources | Data Sources
Applications | Applications Analytics
到目前为止,我已经做到了:
<table class="table table-bordered">
<thead>
<tr>
<th>Group</th>
<th>Tags</th>
</tr >
</thead>
<tbody>
<tr ng-repeat="tag in topic.tags | groupBy: 'topParentId'">
<td>{{tag.topParentText}}</td>
</tr>
<tr>
<td>{{tag.text}}</td>
</tr>
</tbody>
</table>
但是运行这段代码后,我得到了Unknown provider: groupByFilterProvider <- groupByFilter
错误.
But after running this code, I am getting Unknown provider: groupByFilterProvider <- groupByFilter
error.
我正在使用AngularJs 1.2
推荐答案
@jhadesdev提到的orderBy
是现成可用的,但不是groupBy
.它包含在 angular-filter
As mentionned by @jhadesdev orderBy
is available out of the box, but not groupBy
.It is included in angular-filter
这篇关于AngularJS-未知提供程序:groupByFilterProvider<-groupByFilter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!