首页 > 解决方案 > 隐藏基于Angularjs中的状态值

问题描述

我的 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 值

标签: angularjsangularjs-ng-repeatejs

解决方案


如果您试图隐藏整行,则只需将 移动ng-if<tr>元素并从所有<td>. 这将隐藏整行。

如果您想隐藏它,<thead>那么我不确定您为什么要隐藏它。如果您想编辑主题,我可以编辑我的答案,并且可以让我更深入地了解您正在尝试的内容。


推荐阅读