angularjs - 隐藏基于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 值
解决方案
如果您试图隐藏整行,则只需将 移动ng-if
到<tr>
元素并从所有<td>
. 这将隐藏整行。
如果您想隐藏它,<thead>
那么我不确定您为什么要隐藏它。如果您想编辑主题,我可以编辑我的答案,并且可以让我更深入地了解您正在尝试的内容。
推荐阅读
- matlab - 将 3d matlab 矩阵重塑为具有索引和值的 2d 矩阵
- asp.net-core - ASP.Net Core 2.1 中关于 Razor 页面的自定义路由
- javascript - Vue从特定索引到特定索引迭代数组
- javascript - 用于边缘 / Internet Explorer 的 d3 svg 文本阴影
- google-apps-script - ReferenceError:未定义“AdminDirectory”
- python - 将多个数据框合并在一起
- express - 未导入嵌入式节点红色中的自定义调色板
- javascript - Bootstrap 模态覆盖关闭事件
- objective-c - objc_release 中的 EXC_BAD_ACCESS(由于 URLByResolvingBookmarkData?)
- javascript - 使用 JavaScript 和 Wix 网站构建器读取 JSON 文件