From b4eed8ad94ce9719540462c1ee969dfd3c6b2355 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 11 Feb 2014 09:57:04 -0500 Subject: feat(filterFilter): support deeply nested predicate objects Due to 339a165, it became impossible to filter nested properties of an object using the filterFilter. A proposed solution to this was to enable the use of nested predicate objects. This change enables the use of these nested predicate objects. Example: ```html
``` Or ```js $filter('filter')(items, { address: { country: 'Canuckistan' } }); ``` Closes #6215 Related to #6009 --- src/ng/filter/filter.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/ng') diff --git a/src/ng/filter/filter.js b/src/ng/filter/filter.js index eabe84a7..2bb0d174 100644 --- a/src/ng/filter/filter.js +++ b/src/ng/filter/filter.js @@ -136,6 +136,15 @@ function filterFilter() { }; } else { comparator = function(obj, text) { + if (obj && text && typeof obj === 'object' && typeof text === 'object') { + for (var objKey in obj) { + if (objKey.charAt(0) !== '$' && hasOwnProperty.call(obj, objKey) && + comparator(obj[objKey], text[objKey])) { + return true; + } + } + return false; + } text = (''+text).toLowerCase(); return (''+obj).toLowerCase().indexOf(text) > -1; }; -- cgit v1.2.3