在搜索框中搜索时不存在子元素时隐藏父块
Hide parent block when child element is not present while searching in searchbox
在搜索框中搜索时,如果子元素不存在,如何隐藏父元素。这是我的代码:
<div class="col-md-6" ng-repeat="round in displaymatch.allrounds>
<h3>Round: {{round.name}}</h3>
<div ng-repeat="teamname in round.matches | filter:namesearch">
<b>Match Date:</b> {{teamname.date}}
<a ng-href="#!/15/{{teamname.date}}/{{teamname.team1.code}}/{{teamname.team2.code}}">{{teamname.team1.name}} <strong>V/S</strong>
{{teamname.team2.name}}</a>
</div>
正常搜索元素是有效的,但搜索不存在的关键字应该也隐藏主要块(回合)。
正常功能:
这是我面临的问题:
使用ng-show
仅在过滤后有 >0 个匹配项时才显示标题:
<div class="col-md-6" ng-repeat="round in displaymatch.allrounds>
<h3 ng-show="(round.matches | filter:namesearch).length > 0">Round: {{round.name}}</h3>
<div ng-repeat="teamname in round.matches | filter:namesearch">
<b>Match Date:</b> {{teamname.date}}
<a ng-href="#!/15/{{teamname.date}}/{{teamname.team1.code}}/{{teamname.team2.code}}">{{teamname.team1.name}} <strong>V/S</strong>
{{teamname.team2.name}}</a>
</div>
类似于this答案。
在搜索框中搜索时,如果子元素不存在,如何隐藏父元素。这是我的代码:
<div class="col-md-6" ng-repeat="round in displaymatch.allrounds>
<h3>Round: {{round.name}}</h3>
<div ng-repeat="teamname in round.matches | filter:namesearch">
<b>Match Date:</b> {{teamname.date}}
<a ng-href="#!/15/{{teamname.date}}/{{teamname.team1.code}}/{{teamname.team2.code}}">{{teamname.team1.name}} <strong>V/S</strong>
{{teamname.team2.name}}</a>
</div>
正常搜索元素是有效的,但搜索不存在的关键字应该也隐藏主要块(回合)。
正常功能:
这是我面临的问题:
使用ng-show
仅在过滤后有 >0 个匹配项时才显示标题:
<div class="col-md-6" ng-repeat="round in displaymatch.allrounds>
<h3 ng-show="(round.matches | filter:namesearch).length > 0">Round: {{round.name}}</h3>
<div ng-repeat="teamname in round.matches | filter:namesearch">
<b>Match Date:</b> {{teamname.date}}
<a ng-href="#!/15/{{teamname.date}}/{{teamname.team1.code}}/{{teamname.team2.code}}">{{teamname.team1.name}} <strong>V/S</strong>
{{teamname.team2.name}}</a>
</div>
类似于this答案。