J99
J99

Reputation: 489

Angular filter related data

I am still fairly new to angular so I was wondering how to best do something like this:

In my controller I have functions bound to $scope to allow me to filter by type.

Now in my template

<div ng-repeat="item in data | filter:isCourse">
... display course data
   <div ng-repeat="item in data | filter.isTutorial">
   ... display tutorial data

I would like to find a way to make sure the tutorials displayed match the id of the currently displayed course.

Any suggestions?

Thanks! - V

Upvotes: 1

Views: 80

Answers (1)

Pankaj Parkar
Pankaj Parkar

Reputation: 136144

You should have then be specific with filters, but do make sure that JSON should be in correct format, as I can see most of the values are not there wrap in "(double quotes)

HTML

<div ng-repeat="course in data | filter: {type: 'course'}">
... display course data
   <div ng-repeat="tut in data | filter: { related_course: course.id }">
   ... display tutorial data

Working Fiddle(Thanks @AWolf)

Upvotes: 1

Related Questions