通过选择和复选框过滤角度

时间:2016-11-05 17:59:50

标签: angularjs angularjs-filter

想要在选择框和我在复选框中实现的复选框中过滤出值,但无法从复选框中获取

MY PLUNKER DEMO

1 个答案:

答案 0 :(得分:0)

Example Here。对复选框使用单个对象,然后可以在过滤器中使用比较器函数,如下所示:

$scope.checkMake = function(value) {

  //Assume no filter is applied so the value will be shown.
  var result = true;

  for (var i in $scope.selected) {
      if ($scope.selected[i] === true) {
          //if we get here, we know a filter is applied, so 
          //check to see if the passed value is one of the selected 
          //checkboxes
          result = $scope.selected[value];
          break;
      }
  }
  return result;
}