0

Right now I have an array of complex objects that have objects inside of objects. I'm trying to use an input field to filter down the list (in an ng-repeat), but for some reason I'm only getting results from the top level.

[
  {
    "id": 1,
    "guid": "a97f722e-cef4-a125-351b-77c281c88556",
    "groups": [
      {
        "name": "Another Test",
        "id": 1
      },
      {
        "name": "Angular",
        "id": 9
      }
    ],
    "addresses": [
      {
        street: "123 Test Ave",
        city: "New York",
        state: "New York"
      }
    ]
  },
  {
    "id": 2,
    "guid": "a97fbbbb-cccc-a125-351b-77c281c88556",
    "groups": [
      {
        "name": "Garbage",
        "id": 2,
        "stuff": [
          {
            "name": "Dennis",
            "anothernest": [
              {
                "test": "Bob"
              },
              {
                "test": "Bob2"
              }
            ]
          }
        ]
      },
      {
        "name": "Test",
        "id": 7
      }
    ],
    "addresses": [
      {
        "street": "345 Test Ave",
        "city": "Los Angeles",
        "state": "California"
      }
    ]
  }
]

This is a similar structure (albeit simplified). For some reason though I have no problem filtering any of these nested objects based on a search: http://jsfiddle.net/7aeL2yd2/

What would prevent me from doing this on a bigger data structure?

Edit Looks like it's an Angular 1.3 issue. It worked on 1.2, but when I upgrade it to 1.3 (like my app is) it no longer works. http://jsfiddle.net/7aeL2yd2/2/

6
  • Your filter seems to work fine on the nested objects. Commented Dec 17, 2014 at 17:43
  • @SoluableNonagon: It does on here, but not on my app, that's what I can't figure out. It's essentially the same code... Commented Dec 17, 2014 at 17:49
  • @SoluableNonagon: Okay, so I did a test with 2 of my objects from my app and it worked just fine with this code. Can the filter function just not handle all off them together (19,000 lines of parsed JSON) so it won't go into the nested objects? Commented Dec 17, 2014 at 18:16
  • It will handle 19000 lines, but it will probably be slow. If you have chrome, you can try profiling to see memory usage and see if your browser slows down. Commented Dec 17, 2014 at 18:25
  • if you cannot show us an example that doesn't work, we cannot really help you. see stackoverflow.com/help/mcve Commented Dec 17, 2014 at 18:27

1 Answer 1

2

This issue was raised seven days ago on GitHub:

fix(filterFilter): filter deep object by string

And it looks like a fix for it was checked in 12 hours ago:

fix(filterFilter): make $ match properties on deeper levels as well

I don't really know how AngularJS's build workflow works or how they release brand new versions, but at any rate, it looks like a solution for your issue is on the way. In the meantime, perhaps you can get by with version 1.2?

Sign up to request clarification or add additional context in comments.

1 Comment

I ended up writing my own filter, but it's good to know I wasn't crazy. Thanks for pointing this out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.