0

I have this markup:

 <div class="row" ng-repeat="value2 in requirements | orderBy:'ControlGroupIdentifier'">
    <div class="col-lg-12">
        <div ng-repeat="controlgroup in value2.ControlGroup"
             ng-show="controlgroup.ListOfControls.length > 0">
            <table ng-if="controlgroup.ListOfControls.length > 0">
                <tbody>
                    <tr ng-repeat="value in controlgroup.ListOfControls = (controlgroup.ListOfControls  | filter: searchCompanyControl )">
                      &nbsp;
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

What I'm trying to do is hide the first div which has the ng-repeat for requirements if all control groups are hidden based on

controlgroup.ListOfControls.length > 0

I'm able to hide the second div ng-repeat but I'm not sure how to hide the most outer ng-repeat if all the control groups in the requirement are hidden based on the condition that there are no list of controls.

halfer
  • 19,824
  • 17
  • 99
  • 186
Laziale
  • 7,965
  • 46
  • 146
  • 262

1 Answers1

-1

You could use "ng-if" on the top div.

<div class="row" ng-if="controlgroup.ListOfControls.length > 0" ng-repeat="value2 in requirements | orderBy:'ControlGroupIdentifier'">

I am not sure if this would cancel your ng-repeat or not, but if it does, you could wrap it in its own div.

eg.

<div ng-if="controlgroup.ListOfControls.length > 0">
  <div class="row" ng-repeat="value2 in requirements | orderBy:'ControlGroupIdentifier'">

Please let me know if this helps!

  • 1
    I think the control group is declared in the inner scope and will not work above, but let me try – Laziale Dec 04 '18 at 19:16
  • You are right, controlgroup would be referring go the value2 itself. Hmm... – Heads_Tails_Hails Dec 04 '18 at 19:24
  • You might be better suited filtering before your repeat. Here's the idea https://code.i-harness.com/en/q/16679c7. Please comment if you find a more efficient (in-dom) way of doing it! I am dealing with something similar. – Heads_Tails_Hails Dec 04 '18 at 19:28