i have case in have nested loops in child 1 constructed filter function takes parent argument. have filter text comparison. here example
<div ng-repeat="group in groups"> {{group.name}} <div ng-repeat="material in materials | filter:filterbygroup(group) | filter:search "> {{material.name}} </div> </div>
now, problem when filter:search
applied , filters out results in specific group, hide group (and not leave empty group.name
hanging without child elements).
i don't have materials in group self, don't have information in parent ng-repeat scope. question if there way can access nested ng-repeat , see count parent , hide parent if count 0.
update
here fiddle better explains situation: fiddle
the main problem don't want associate materials groups. if nothing else works, sounds overload (since need filter results twice) if checking nested loop.
thanks
a cleaner solution suggested here.
what need wrap relevant area ng-show / ng-if based on expression applies filter on data structure , extracts length. here how works in example:
<div ng-show="(materials | filter:filterbygroup(group)).length"> <div ng-repeat="group in groups"> {{group.name}} <div ng-repeat="material in materials | filter:filterbygroup(group) | filter:search "> {{material.name}} </div> </div> </div>
this allows hide complex structures once empty due filtering, e.g. table of results.
Comments
Post a Comment