$scope.hide_emptytable() = function{
if ($.trim($('.acf-dynamic-table .field').text())=="") {
$('.acf-dynamic-table').hide();
}
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<div ng-repeat="t in[]">
<table class="acf-dynamic-table">
<tr>
<td>Name</td>
<td>Address</td>
</tr>
<tr>
<td class="field">t.name</td>
<td class="field"><span>t.ward_no</span> <span>t.street</span> <span>t.city</span> <span>t.state</span> <span>t.postcode</span></td>
</tr>
</table>
</div>
<div ng-repeat="t in []">
<table class="acf-dynamic-table">
<tr>
<td>Name</td>
<td>Address</td>
</tr>
<tr>
<td class="field"></td>
<td class="field"><span></span> <span></span> <span></span> <span></span> <span></span></td>
</tr>
</table>
</div>
<span style="display : none">{{hide_emptytable()}}</span>
如果带有类字段的列值为空,我想隐藏表格。例如,应该隐藏第二个表但它不起作用。 对于地址,值在它们之间的一个空间内跨越。
答案 0 :(得分:0)
我会更改hideempty表以返回布尔值并在表格中使用ng-if =“hide_emptytable”。
$(function() {
Dropzone.options.myZone = {
success: function(){
location.reload();
}
};
});
答案 1 :(得分:0)
正确的代码应该是
$scope.hide_emptytable = function(){
return $.trim($('.acf-dynamic-table .field').text()) == "";
}
然后你应该使用ng-show
ng-show = hide_emptytable()
建议不要将jquery与angularjs.Angularjs混合使用MVVM模式,你可以充分利用角度函数来实现你想要的而不是写hide()
。
答案 2 :(得分:0)
您可以使用此代码解决问题。
$(function(){
$('.acf-dynamic-table .field')
.has('span')
.each(function(){
if($(this).children().not(':empty').length == 0)
$(this).parents('table').hide();
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div id='print'></div>
<div ng-repeat="t in[]">
<table id='1' class="acf-dynamic-table">
<tr>
<td>Name1</td>
<td>Address1</td>
</tr>
<tr>
<td class="field">t.name</td>
<td class="field"><span>t.ward_no</span> <span>t.street</span> <span>t.city</span> <span>t.state</span> <span>t.postcode</span></td>
</tr>
</table>
</div>
<div ng-repeat="t in []">
<table id='2' class="acf-dynamic-table">
<tr>
<td>Name2</td>
<td>Address2</td>
</tr>
<tr>
<td class="field"></td>
<td class="field"><span></span> <span></span> <span></span> <span></span> <span></span></td>
</tr>
</table>
</div>
&#13;