我已根据用户的条目以及日期比较过滤模型。我想在过滤器没有返回结果时显示一条消息。我已经看到了这个问题的其他答案,我似乎无法使它们发挥作用。
以下是我的ng-repeat设置:
<div ng-repeat="docs in casedocs | filter: filterDocuments |
orderBy: userSort : userSortDirection ">
<div style="float:left;padding-right:4px;" class="documentRadios">
<input type="radio" ng-model="docviews[0].docID"
ng-show="typeOfLaw != 'CV'" value="{{docs.DocID}}"
ng-change="loadDocument(1,
'{{docs.Description}}', {{docs.DocID}})" />
<input type="radio" ng-model="docviews[1].docID"
ng-show="typeOfLaw != 'CV'" value="{{docs.DocID}}"
ng-change="loadDocument(2,
'{{docs.Description}}', {{docs.DocID}})" />
</div>
<div class="documentTitle">
<a href ng-click="loadDocument(1,
docs.Description, docs.Doc_ID)">
{{docs.Description}}
</a>
<span class="documentFilingDate">
({{docs.DocFilingDate}})
</span>
</div>
<div class="documentIcons">
<a href="docview/{{docs.DocID}}" target="_blank">
<span class="glyphicon glyphicon-new-window white smaller">
</span>
</a>
<span ng-show="docs.Image_Type_ID == 3" class="glyphicon
glyphicon-search white smaller"></span>
<span ng-show="docs.Security_Level > 0" class="glyphicon
glyphicon-lock white smaller"></span>
<span ng-show="docs.QC_Review_Status == 1" class="glyphicon
glyphicon-ok white smaller"></span>
</div>
<div style="clear:both;"></div>
</div>
<div class="col-sm-8">
<span class="notFound white">{{noDocumentsMsg}}</span>
</div>
</div>
根据示例,我发现我应该更改ng-repeat声明,如下所示:
<div ng-repeat="docs in casedocs = (doc | filter: filterDocuments)
| orderBy: userSort : userSortDirection ">
然后使用基于ng-show
的{{1}},但是当我添加所有过滤中断时。我见过的例子没有orderBy语句。我在这里做错了什么?
答案 0 :(得分:1)
假设您的数据位于$scope.casedocs
,请尝试:
<div ng-repeat="docs in filteredCasedocs = (casedocs | filter: filterDocuments | orderBy: userSort : userSortDirection)">
<!-- your code -->
</div>
<div ng-show="!filteredCasedocs.length">None avaialble</div>