Скрытие <thead>на основе значения статуса в Angularjs - PullRequest
0 голосов
/ 28 сентября 2018

Код моего Ejs:

<div ng-repeat="doc_insp in inspection_status" class="inspec-divider"> 
       <span class="inspec-title">{{doc_insp.insName}}</span>
  <table class="table table-striped ins-table " dir-paginate="doc in doc_insp.locationAspects | itemsPerPage:itemsPerPage " current-page="currentPage">
      <thead  ng-init="check_ins_status(doc)">
          <tr>
              <td colspan="3">{{itemsPerPage *(currentPage-1)+$index+1}}. {{doc.aspectname}}</td>
          </tr>
          <tr>
              <!-- <td colspan="3">{{itemsPerPage *(currentPage-1)+$index+1}}. {{doc.aspectname}}</td> -->
              <td>{{statusgrp}}</td>
          </tr>
          <tr>

              <th id="apt" scope="col" width="150">Comments</th>
              <th  id="chal" scope="col" width="150">Recommentations</th>
              <th id="villa" scope="col" width="150">Rectification Status</th>
          </tr>
      </thead>
    <tbody>
       <tr ng-repeat="comment in doc.comments" > 
         <td  ng-if="(comment.status_id.indexOf('<%= inspection_id %>'.toString()) != -1 && comment.status=='C') || comment.status=='P' || comment.status=='O' || comment.status=='R' ">{{comment.comment[0]}}</td>
         <td  ng-if="(comment.status_id.indexOf('<%= inspection_id %>'.toString()) != -1 && comment.status=='C') || comment.status=='P' || comment.status=='O' || comment.status=='R' ">{{comment.recommendation}}</td>
         <td  ng-if="(comment.status_id.indexOf('<%= inspection_id %>'.toString()) != -1 && comment.status=='C') || comment.status=='P' || comment.status=='O' || comment.status=='R' ">
          <select  name="status" id="status" class="txt_box sel_box" ng-model="comment.status" ng-change="update_insstatus(comment,doc._id,doc_insp._id,'<%= project_id%>','<%= inspection_id %>')">
              <option  disabled value="">Select Type</option>
              <option  value="O" >Open</option>
              <option  value="P" >Pending</option>
              <option  value="C" >Closed</option>
              <option  value="R" >Rejected</option>

          </select>
         </td>
       </tr>
    </tbody>

  </table>
  </div>

Я скрываю комментарий, основанный на значении статуса (если это C, он не должен быть видимым, а если все комментарии - C, тогда имя аспекта не должно быть видимым)

Мой угловой код:

$scope.check_ins_status = function(comment){

if(comment){
    console.log(comment)
    console.log(comment.comments)
    $scope.statusgrp = [];
    angular.forEach(comment.comments, function(value, key){
        console.log(value.status);
        $scope.statusgrp.push(value.status)
      });
console.log($scope.statusgrp); // Here am getting array for each time but in ejs last array only showing 
}       
}

Как скрыть полностью основанное на значении comment.status значение

1 Ответ

0 голосов
/ 28 сентября 2018

Если вы пытаетесь скрыть всю строку, просто переместите ng-if к элементу <tr> и удалите все элементы <td>.Это скрыло бы весь ряд.

Если вы пытаетесь скрыть <thead>, тогда я не уверен, почему вы захотите скрыть его.Я могу отредактировать свой ответ, если вы хотите отредактировать thead и дать мне больше понимания того, что вы пытаетесь.

...