我将以下json作为来源:
"available_examinators": [
{
"id": 4,
"user": {
"email": "mail",
"first_name": "First_name",
"last_name": "Last_name",
},
"courses": [
{
"id": 1,
}
]}]
连同以下html:
<md-option ng-value="examinator"
ng-repeat="examinator in uf.data.orderData.available_examinators
track by examinator.id |
filter: { examinator {courses : { id : course.id }}}">>
我想过滤,因此它只显示具有特定课程ID的考官,但我无法使用它。
答案 0 :(得分:1)
以上内容几乎是正确的,但它使我得到了正确的答案,除了上述更改之外,我还必须跟踪到表达式的末尾,否则我仅尝试根据examinator.id进行过滤
正确的答案是:
<md-option ng-value="examinator" ng-repeat="examinator in uf.data.orderData.available_examinators | filter: { courses: {id: course.id}} track by examinator.id">
答案 1 :(得分:0)
您非常接近,这是正确的语法:
<md-option ng-value="examinator"
ng-repeat="examinator in uf.data.orderData.available_examinators
| filter: {courses : { id : course.id }} track by examinator.id">
查看有效的演示:DEMO
编辑:
track by
表达式必须排在最后-在所有过滤器和别名表达式之后