I have a collection of elements. Some of these elements are considered "children" of other elements known as "parent" elements. Instead of rearranging the JSON data received from the server, I am attempting to filter the results within the ng-repeat loop. Each element in the collection has an id and a property called "father_id". If this property is set to 0, it indicates that the element is a parent. The issue I'm facing is filtering the inner loop based on values from the parent loop.
Here is how I successfully filter the parent elements in the loop:
ng-repeat="fatherElement in pageInitialAjaxContent | filter:{father_id:0}"
This displays all elements with a "father_id" of 0, indicating they do not have a parent which makes them parents themselves.
For the inner loop, my unsuccessful attempt looks like this:
ng-repeat="childElement in pageInitialAjaxContent | filter:{father_id:fatherElement.id}"
The goal here is to filter items where the father ID matches the ID of the parent element. However, this approach yields unexpected results.
Could someone provide guidance on how to properly construct this expression?