I'm trying to filter an array of javascript objects by a string. But I want the filter to look at every property and test it to see if the string is valid. AngularJS has a built in filter that does this, but I can't find any solutions for it on SO.
[
{
"title":"Mr.",
"name":"John Smith",
"firstName":"John",
"lastName":"Smith"
},
{
"title":"Mr.",
"name":"Bill Smith",
"firstName":"Bill",
"lastName":"SMith"
}
]
So for example if I entered 'Jo' for the text string it would bring back the object at index 0, which is pretty easy to do if you just want to search by a single property.
Now if I enter 'Mr' it should bring back both items at index 0 and index 1 because we're searching all of the properties.
Hope this makes sense as to what I'm asking.
EDIT: Very sorry was a late night last night and I left off very significants details in the data structure.
{
"title":"Mr.",
"name":"John Smith",
"firstName":"John",
"lastName":"Smith",
"contactType":{
"name":"test"
},
"addresses":[
{"address":"Test Street One"},
{"address":"Test Street Two"},
]
},
{
"title":"Mr.",
"name":"Bill Smith",
"firstName":"Bill",
"lastName":"SMith",
"contactType":{
"name":"test"
},
"addresses":[
{"address":"Test Street One"},
{"address":"Test Street Two"},
]
}
So in this scenario the search would account for any type and any number of nested objects within objects. Sorry for forgetting this part.