AngularJS过滤嵌套对象

AngularJS过滤嵌套对象,第1张

AngularJS过滤嵌套对象

是的,如果我正确理解您的示例,则可以。

根据集合的大小,计算迭代所用的集合可能会更好,

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;};


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5427897.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存