Avatar of websss
Flag for Kenya

asked on 

Angular filtering multi-dimensional object by another object

I have an app I'm building in Ionic using Angular, and am having difficulty incorporating a filter of assets by the groups those assets are associated with.  

"vehicles": [
    {"id": 1, "make": "Ford", "seats": 4},
    {"id": 2, "make": "Tata", "seats": 2},
    {"id": 3, "make": "Toyota", "seats": 12}
    {"id": 4, "make": "Dodge", "seats": 4}

        {"id": 1, "name": "utility", "members": [{"id": 3},{"id": 4}]},
        {"id": 2, "name": "vacation", "members": [{"id": 2}]},
        {"id": 3, "name": "general", "members": [{"id": 1}]}

I'm getting my data via a service, and want to filter my vehicles based on a selection among the listed groups (so if I select "utility" vehicles, only the Dodge and Toyota will show up).  Further, I'd also like it to display all vehicles if no groups are selected.  

I'd like to do this without using any nested loops if possible.  Also, this SO thread seems very similar: http://stackoverflow.com/questions/21690721/filtering-ng-repeat-list-using-checkboxes-and-angularjs, but I haven't been able to get it to work yet.  Any suggestions?

Avatar of undefined
Last Comment

8/22/2022 - Mon