diff options
| -rw-r--r-- | src/Angular.js | 3 | ||||
| -rw-r--r-- | src/ng/filter/filter.js | 9 | ||||
| -rw-r--r-- | test/ng/filter/filterSpec.js | 11 | 
3 files changed, 22 insertions, 1 deletions
| diff --git a/src/Angular.js b/src/Angular.js index 9811c363..e9d1de88 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -81,6 +81,7 @@      -assertNotHasOwnProperty,      -getter,      -getBlockElements, +    -hasOwnProperty,  */ @@ -96,7 +97,7 @@   * @returns {string} Lowercased string.   */  var lowercase = function(string){return isString(string) ? string.toLowerCase() : string;}; - +var hasOwnProperty = Object.prototype.hasOwnProperty;  /**   * @ngdoc function 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;          }; diff --git a/test/ng/filter/filterSpec.js b/test/ng/filter/filterSpec.js index 0bb48704..7679136a 100644 --- a/test/ng/filter/filterSpec.js +++ b/test/ng/filter/filterSpec.js @@ -70,6 +70,17 @@ describe('Filter: filter', function() {    }); +  it('should support deep predicate objects', function() { +    var items = [{person: {name: 'John'}}, +                 {person: {name: 'Rita'}}, +                 {person: {name: 'Billy'}}, +                 {person: {name: 'Joan'}}]; +    expect(filter(items, {person: {name: 'Jo'}}).length).toBe(2); +    expect(filter(items, {person: {name: 'Jo'}})).toEqual([ +      {person: {name: 'John'}}, {person: {name: 'Joan'}}]); +  }); + +    it('should match any properties for given "$" property', function() {      var items = [{first: 'tom', last: 'hevery'},                   {first: 'adam', last: 'hevery', alias: 'tom', done: false}, | 
