AngularJS 只显示某些类别
问题我认为这是一个长镜头,但希望有人能帮助我,下面是我认为我得到所有类别的部分,但我只想显示某些类别,而不是所有类别。在图像中,我有完整的分类,但我希望材料部分不出现,但在后台仍然具有搜索功能
<div class="ng-cloak" ng-app="angularDemo" ng-cloak="">
<div ng-controller="angularController as ctrl">
<div class="hidden-xs" id="filter_desktop" layout="row">
<div class="container">
<div class="col-sm-2" style="padding-left: 0px;margin-left: -47px;margin-right: 46px;">
<div class="filter" style="color: #999;font-weight: 100;font-size: 120%;margin-right: -60px;"><span>FILTER YOUR SEARCH</span></div>
<div class="resetFilter">
<center class="text-left" style="color: #999;"><button id="resetFilter" onclick="window.location.href='" type="button"><img alt="" src="/Data/Sites/1/media/collection/reset-icon-614x460.png" style="height: 30px!important;" />RESET FILTERS</button></center>
</div>
<div class="sidebar" style="border-top: 1px solid #c1c1c1;">
<div ng-repeat="filter in Filters" style="border-bottom: 1px solid #c1c1c1;">
<div class="col-sm-1" style="margin-right: -30px;"><button ng-click="filter.expanded = false" ng-if="filter.expanded" style="margin-left: 140px; background-color: transparent;border: none;font-size: 25px;margin-top: -34px;">+</button><button ng-click="filter.expanded = true" ng-if="!filter.expanded"
style="margin-left: 140px;background-color: transparent;border: none;font-size: 45px;margin-top: -34px;">-</button></div>
<h3 class="sort" style="font-size: 18px;font-weight: 100;text-transform: uppercase;margin-bottom: 15px;">{{filter.name}}</h3>
<div class="sortoptions" style="margin-bottom: 15px;">
<div data-hidden-checkbox="{{ filter.name == 'family'}}" ng-if="!filter.expanded" ng-repeat="option in filter.options | orderBy: 'value'" style="line-height: 1.6;"><input id="{{option.value}}" ng-checked="option.IsIncluded" ng-model="option.IsIncluded" style="margin-bottom: -1px!important;" type="checkbox" /> <label for="{{option.value}}">{{option.value}}</label></div>
</div>
</div>
</div>
</div>
回答
在 codepen 示例中,只需添加
ng-if="filter.name !== 'color'"
遍历此处的过滤器列表( ng-repeat )。仅当过滤器的名称不是颜色时才会呈现 div。
这是最新的密码笔。
页:
[1]