我尝试过滤包含在超链接中的多个项目标题的 ng-repeat View ,但根据标题和 URL 字符串值获取结果。
如何将过滤器限制为仅包含标题文本并忽略 URL 中的肯定内容?例如。如果我搜索“电子邮件”,我会得到标题或文本正文中包含“电子邮件”的项目的结果,但我也会得到 URL 字符串中包含“电子邮件”的结果。
<a href="http://google.com?q=email">Search Google for email</a><p>Blah blah blah</p>
非常感谢任何帮助!
<div ng-app="Home">
<div ng-controller="Details">
<div class="row">
<div class="col-xs-12 col-sm-5 col-md-4 col-lg-4">
<div class="searchBox">
<input type="search" ng-model="search"/>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4" ng-repeat="SectionItem in Sections" ng-init="filterResult=[]" ng-hide="filterResult[$parent.$index].length <= 0">
<div class="panel panel-default">
<div class="panel-body">
<div>
<h1>{{SectionItem.Title}}</h1>
</div>
<div>
<!-- BEGIN: items belonging to this section -->
<table class="table table-condensed table-hover">
<tr ng-repeat="item in (filterResult[$parent.$index] = (SectionItems | filter:search | filterByMatchingSection:SectionItem.Title)) ">
<td>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12" ng-show="item.Title != null">
<a href="{{item.URL}}">{{item.Title}}</a>
<p>
{{item.TextBody}}
</p>
</div>
</div>
</div>
</td>
</tr>
</table>
<!-- END: items belonging to this section -->
</div>
</div>
</div>
</div>
</div>
</div>
最佳答案
这应该可以解决问题
<input type="search" ng-model="search.Title"/>
关于javascript - 过滤 View 时需要 ng-repeat 过滤器来忽略任何超链接字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33658089/