Reputation: 57
I got the following json as source:
"available_examinators": [
{
"id": 4,
"user": {
"email": "mail",
"first_name": "First_name",
"last_name": "Last_name",
},
"courses": [
{
"id": 1,
}
]}]
together with the following 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 }}}">>
I want to filter so it only shows examinators that have an specific course id but I dont get it to work.
Upvotes: 0
Views: 67
Reputation: 3618
You are very close, this is the correct syntax:
<md-option ng-value="examinator"
ng-repeat="examinator in uf.data.orderData.available_examinators
| filter: {courses : { id : course.id }} track by examinator.id">
Check a working demo: DEMO
EDIT: the
track by
expression must come last - after any filters, and the alias expression
Upvotes: 0
Reputation: 57
Above was almost correct but it led me to the right answer, beside the above changes I had to move track by to the end of the expression else I tried to filter on only examinator.id
So the correct answer is:
<md-option ng-value="examinator" ng-repeat="examinator in uf.data.orderData.available_examinators | filter: { courses: {id: course.id}} track by examinator.id">
Upvotes: 1