javascript - How to define custom filter for ui-select module in AngularJS? -


here code select-field in html:

<ui-select ng-model="group.selected" theme="selectize" ng-click="searchdisabled(3)" ng-disabled="disabledgroup">    <ui-select-match placeholder="choose group">        {{$select.selected.name}}    </ui-select-match>    <ui-select-choices repeat="group in groups | filter: $select.search">       <span ng-bind-html="group.name | highlight: $select.search"></span>       <small ng-bind-html="group.code | highlight: $select.search"></small>    </ui-select-choices> </ui-select> 

then field who's important filter table list:

<tr ng-repeat="item in filterednames = (nameslist | filter:search | selectgroup:group.selected)">    <td>{{ item.lname }}</td>    <td>{{ item.fname }}</td>    <td>{{ item.maxage }}</td> </tr> 

i'm using ngmodel value ui-select-tag in custom filter selectgroup parameter filter.

the nameslist values coming database. here json result of request qr_group db-table:

{   "qr_name":[     { "id":31, "lname":"bricks", "fname":"johnny", "maxage":24, "qr_groupid":6 },     { "id":4, "lname":"schon", "fname":"toni", "maxage":54, "qr_groupid":6 },     { "id":56, "lname":"houston", "fname":"monica", "maxage":29, "qr_groupid":6 },    ],   "id":6,   "name":"south america",   "code":"sa" } 

this json format i'm getting webapi method getgroup. how can display qr_name array on table list custom filter?

this first thought:

testapp.filter('selectgroup', ['$log', function ($log) {     return function (nameslist, group) {         group = group || '';         $log.info('fondslist:', fondslist);         $log.info('filter group:', group);         var selectlist = [];          angular.foreach(fondslist, function (input) {             if (group == input.qr_name['qr_groupid']) {                 selectlist.push(input);             }         });     } }]); 

but filter doesn't work correctly.

angular ui-select added support custom filters in 0.12 group-filter attribute - https://github.com/angular-ui/ui-select/pull/836


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -