隐藏如果在角没有数据 [英] Hide if there is no data in angular
问题描述
<表>
< TR NG重复=(键,值)中的myData>
&所述; TD> {{键}}< / TD>
&所述; TD>
< DIV NG重复=项的值| limitTo:限制|过滤器:{来源:sourceFilter}NG-包括='模板/ item.html'/>
< / TD>
< / TR>
< /表>
通过上面的code我通过按键/值循环,其中,key是一个字符串值是一个数组。我对源过滤值
属性 - 这意味着有时候某些键没有显示的项目。我想隐藏所有没有任何项目行。
我一直在使用自定义过滤器试过了, NG-节目
/ NG-隐藏
,但我是一个角小白我似乎无法弄清楚如何做到这一点。可能有人告诉我,我怎么能做到这一点的例子吗?非常感谢。
尝试:
<表>
< TR NG重复=(键,值)中的myData
NG-隐藏=(值|过滤器:{来源:sourceFilter)。长度== 0>
&所述; TD> {{键}}< / TD>
&所述; TD>
< DIV NG重复=项的值| limitTo:限制|过滤器:{来源:sourceFilter}NG-包括='模板/ item.html'/>
< / TD>
< / TR>
< /表>
在<大骨节病> Plunker 骨节病> 一些示例p>
<table>
<tr ng-repeat="(key, values) in myData">
<td> {{ key}} </td>
<td>
<div ng-repeat="item in values| limitTo:limit | filter: {source: sourceFilter}" ng-include="'templates/item.html'"/>
</td>
</tr>
</table>
With the above code I looping through the keys/values, where key is a string and value is an array. I am filtering the values by the 'source'
property - this means that sometimes some keys have no items displayed. I would like to hide all of the rows that do not have any items.
I have tried using custom filters, and ng-show
/ng-hide
, but as I am an angular noob I can't seem to figure out how to do this. Could someone show me an example of how I can achieve this ? Many thanks.
Try:
<table>
<tr ng-repeat="(key, values) in myData"
ng-hide="(values | filter: {source: sourceFilter).length == 0">
<td> {{ key}} </td>
<td>
<div ng-repeat="item in values| limitTo:limit | filter: {source: sourceFilter}" ng-include="'templates/item.html'"/>
</td>
</tr>
</table>
Some example in Plunker
这篇关于隐藏如果在角没有数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!