AngularJS仅显示某些类别

时间:2020-04-20 03:39:06

标签: 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;">&nbsp;
          <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>

这里] 1`

1 个答案:

答案 0 :(得分:0)

在您的Codepen示例中,只需添加

ng-if="filter.name !== 'color'"

,您可以在其中遍历过滤器列表(ng-repeat)。仅当滤镜名称不是 color 时,才渲染div。 Here是更新的Codepen。