用ui-select反向过滤

Filter with ui-select Reversely

如何反向过滤 select 选项? 我使用 ui-select 来过滤我的多 select 选项。我可以根据国家过滤城市。 我想添加按城市筛选国家,并在选项中标记国家名称。

请看这个FIDDLE

您需要实现此方法才能执行此操作

$scope.getCityListByCity=function(){
      var sampletemp = [];
      $scope.selected.city.forEach(function(city) {
    var temp =  objectFromArrayFilter($scope.samples,'city',city);
    sampletemp = sampletemp.concat(temp);
            });
      $scope.uniquecountry = $filter('unique')(sampletemp, 'country');
        $scope.selected.country= [];

       $scope.country = $scope.uniquecountry.map(function(item) {
      return item.country
        })
      $scope.selected.country=$scope.country;

      if($scope.country.length == 0){

        $scope.uniquecountry = $filter('unique')($scope.samples, 'country');
    $scope.country = $scope.uniquecountry.map(function(item) {
      return item.country
    })
      }

    }

请根据您的要求参考此工作fiddle