简体   繁体   English

如何使用ui-select group-filter属性?

[英]How to use ui-select group-filter property?

Hey Guys I want to use ui-select. 大家好,我想使用ui-select。 But I got stock on the group-filter property: 但是我在组过滤器属性上有库存:

I got an Array from my server containing groups: 我从服务器中得到一个包含组的数组:

Group looks like this: 组看起来像这样:

{"1":{"id":"1","name":"DLRG Göttingen e.V.","idCategory":"1","categoryName":"Verein"}}

So there are some categories more like family, company and so on. 因此,有些类别更像是家庭,公司等等。

I have to ui-select fields, one for families and an other for all other categories. 我必须ui选择字段,一个字段用于家庭,另一个字段用于所有其他类别。

I tried filtering by using this method: 我尝试使用此方法进行过滤:

filterFamily() {
      var families = {};
// this.groupList contains all groups
      for (var i; i < this.groupList; i++) {
        if (this.groupList[i].idKategorie == 2) {
          families.push(this.groupList[i]);
        }
      }
      return families;
    }

In my html I try to use the filter with: 在我的html中,我尝试将过滤器用于:

   <ui-select ng-model="ctrl.group">
                  <ui-select-match>
                    <span ng-bind="$select.selected.name"></span>
                  </ui-select-match>
                  <ui-select-choices group-filter="ctrl.filterFamily()" repeat="item in ctrl.groupList | propsFilter:{name: $select.search}">
                    <div ng-if="item.isTag"
                         ng-bind-html="item.name +' <small>(new)</small>'| highlight: $select.search"></div>
                    <div ng-if="!item.isTag" ng-bind-html="item.name + person.isTag| highlight: $select.search"></div>
                    <small>
                      {{item.kategorieName}}
                    </small>
                  </ui-select-choices>
                </ui-select>

But in this field all other items are shown too? 但是,在此字段中还显示所有其他项目吗?

Can anyone help me? 谁能帮我? Thanks in advance 提前致谢

I think it needs to be group-filter="ctrl.filterFamily" , not group-filter="ctrl.filterFamily()" , although I have never used this project before. 我认为它应该是group-filter="ctrl.filterFamily" ,而不是group-filter="ctrl.filterFamily()" ,尽管我以前从未使用过此项目。

That is how it's used in the docs though 那就是它在文档中的用法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM