How to create a composite filter with two way binding?

后端 未结 2 842
清酒与你
清酒与你 2021-01-21 11:33

I want to display a list of items in a table and allow users to filter the items using form controls.

My Problem
I am able to accomplish this when t

2条回答
  •  清酒与你
    2021-01-21 11:59

    angular can automatically two-way-bind everything for you without the need for filters:

    JS:

    $scope.filteredRecords = function() {
      return $scope.records.filter(function(record, i) {
        return record.travelerCount === $scope.travelerFilter &&
          record.group === $scope.groupFilter;
      });
    }
    

    HTML:

    
    

    See here for a live example: http://plnkr.co/edit/aeBv2soGG06Trpp9WI4f?p=preview

提交回复
热议问题