【发布时间】:2015-11-04 03:57:18
【问题描述】:
我找到了这个答案:AngularJS - hide parent element if children loop is empty (filtered),但它似乎对我不起作用。
我的代码完美运行,是:
<div ng-repeat="lawyer in articlesByAuthor | orderObjectBy:'lastname':false" ng-show="sortType=='author'">
<h3>{{lawyer.fullname}}</h3>
<br/>
<table border="1">
<thead>
<tr>
<th style="padding: 2px 5px;">
Date Published
</th>
<th style="padding: 2px 5px;">
Article
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="article in lawyer | filter:searchArticle">
<td style="padding: 2px 5px;white-space:nowrap;">
{{article.date | date:'MMM. dd, yyyy'}}
</td>
<td style="padding: 2px 5px;;">
<a href="{{article.link}}" target="_blank" ng-if="article.link != ''"><span ng-bind-html="renderHtml(article.title)" class="articlePage"></span></a><span ng-bind-html="renderHtml(article.title)" class="articlePage" ng-if="article.link == ''"></span>
</td>
</tr>
</tbody>
</table>
<br/><br/>
</div>
但是,如果搜索结果显示没有文章出现,我仍然会卡在一个空表,上面有名字。
基于上述,我尝试将整个东西包装在:
<div ng-show="(lawyer | filter:searchArticle).length">
</div>
无济于事。无论如何都不显示。我已经用article 和articlesByAuthor 替换了lawyer,但都不起作用。
我错过了什么?
【问题讨论】: