Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
Content of "Ng-If ="0" <div>" shows on un-"collapse"

The content of the ng-if still shows if I click the button. But I want it only to show in a specific situation. In another situation the button should unhide a different <div>

I thought the part after ng-if gets removed in the DOM, so I am wondering why it is even able to show up.

<tr>
  <td>{{approval_item.requested_for}}</td>
  <td><a data-toggle="collapse" data-target=".{{approval_item.document_id_number}}"><i class="fa fa-trash"></i></a></td>
</tr>

<div ng-if="0">
  <tr class="hide-table-padding collapse {{approval_item.document_id_number}}">
    <td colspan="5">
      <tr class="collapse {{approval_item.document_id_number}}">
        <td><b>Item / Service</b></td>
        <td><b>Quantity</b></td>
        <td><b>One-time Price</b></td>
        <td><b>Monthly</b></td>
        <td><b>Yearly</b></td>
      </tr>
      <tr class="collapse {{approval_item.document_id_number}}" ng-repeat="requested_item in approval_item.request_ritms">
        <td><a href="{{requested_item.link}}">{{requested_item.name}}</a></td>
        <td>{{requested_item.quantity}}</td>
        <td>{{requested_item.price_string}}</td>
        <td>{{requested_item.price_monthly_string}}</td>
        <td>{{requested_item.price_yearly_string}}</td>
      </tr>
      <tr class="collapse {{approval_item.document_id_number}}">
        <td></td>
        <td></td>
        <td><b>One-time Total</b></td>
        <td><b>Monthly Total</b></td>
        <td><b>Annually Total</b></td>
      </tr>
      <tr class="collapse {{approval_item.document_id_number}}">
        <td></td>
        <td></td>
        <td>{{approval_item.price_string}}</td>
        <td>{{approval_item.price_monthly_string}}</td>
        <td>{{approval_item.price_yearly_string}}</td>
      </tr>
    </td>
  </tr>
</div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem is that div can't be a child of table. If you want to hide the row, you should remove the div and move the ng-if into the tr itself.

Do

angular.module('myApp', [])
  .controller("Ctrl_List", ["$scope", function(s) {}])
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>

<div ng-app="myApp">
  <div class="container" ng-controller="Ctrl_List">
    <table>
      <tr>
        <td>
          row 1
        </td>
      </tr>
      <tr ng-if="0">
        <td>
          row 2
        </td>
      </tr>
    </table>
  </div>
</div>

Don't

angular.module('myApp', [])
  .controller("Ctrl_List", ["$scope", function(s) {}])
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>

<div ng-app="myApp">
  <div class="container" ng-controller="Ctrl_List">
    <table>
      <tr>
        <td>
          row 1
        </td>
      </tr>
      <div ng-if="0">
        <tr>
          <td>
            row 2
          </td>
        </tr>
      </div>
    </table>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!