是的,如果我正确理解您的示例,则可以。
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;};
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)