【发布时间】:2015-11-15 22:52:29
【问题描述】:
我有这些课程:
[{ id: 1, courseId: 2, text: 'John' },
{ id: 2, courseId: 2, text: 'Willi' },
{ id: 3, courseId: 2, text: 'Inga' },
{ id: 4, courseId: 1, text: 'Jerry' },
{ id: 5, courseId: 1, text: 'Michael' },
{ id: 1, courseId: 3, text: 'John' },
{ id: 2, courseId: 3, text: 'Willi' },
{ id: 3, courseId: 4, text: 'Inga' },
{ id: 4, courseId: 5, text: 'Jerry' },
{ id: 5, courseId: 5, text: 'Michael' }]
我有这个 id 数组:
[{"id": 3},{"id": 2},{"id": 1}]
我需要通过 id 数组过滤课程数组(即仅显示具有 courseId = 3,2,1 的文本课程):
ng-repeat="course in courses| customFilter: [{"id": 3},{"id": 2},{"id": 1}]"
我需要在 angularJS 中创建自定义过滤器,该过滤器将按 id 数组过滤课程数组。
知道如何为此目的实现 customFilter 吗?
【问题讨论】:
标签: javascript angularjs data-binding angularjs-filter