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/

m0ngr31
  • 791
  • 13
  • 29
  • Your filter seems to work fine on the nested objects. – SoluableNonagon Dec 17 '14 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... – m0ngr31 Dec 17 '14 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? – m0ngr31 Dec 17 '14 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. – SoluableNonagon Dec 17 '14 at 18:25
  • if you cannot show us an example that doesn't work, we cannot really help you. see http://stackoverflow.com/help/mcve – mb21 Dec 17 '14 at 18:27
  • @mb21: I updated the question. Looks like it no longer works on Angular 1.3. – m0ngr31 Dec 17 '14 at 18:31

1 Answers1

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?

JLRishe
  • 99,490
  • 19
  • 131
  • 169
  • I ended up writing my own filter, but it's good to know I wasn't crazy. Thanks for pointing this out. – m0ngr31 Dec 17 '14 at 21:50