是的,如果我正确理解您的示例,则可以。
根据集合的大小,计算迭代所用的集合可能会更好,
ng-repeat这样过滤器就不会随着模型的更改而不断地进行操作。
http://jsfiddle.net/suCWn/
基本上,如果我理解正确,您会执行以下操作:
$scope.search = function (shop) { if ($scope.selectedCityId === undefined || $scope.selectedCityId.length === 0) { return true; } var found = false; angular.forEach(shop.locations, function (location) { if (location.city_id === parseInt($scope.selectedCityId)) { found = true; } }); return found;};


