Richard
Richard

Reputation: 6116

Angular Operator Searching

I have an angular page with a search bar. I have successfully implemented a search bar and also improved it by using the advanced search box. The table that I have has 2 columns. 1 for the user's name and 2 for the number of items the user has in his/her inventory. This is how the user object comes back in json:

{
    "displayName":"John",
    "items": [
        {
            "name":"foo1",
            "type":"fooType1"
        },
        {
            "name":"foo2",
            "type":"fooType2"
        },
        {
            "name":"foo3",
            "type":"fooType3"
        }
    ]
}

Angular's $http saves that in a data object and all I have to do is say data.items.length. So in my table I would display:

+------+-------+
| Name | Items |
+------+-------+
| John |     3 |
+------+-------+

I want to implement operator searching. So I want the user to be able to say find all users with at least 3 items or find all users with more than 1 item but less than 5. But I have yet to find any search bar features that supports this kind of operator searching. Is there a way to do it with this plugin?

Additionally, is there a way to make these searched case sensitive or search the whole word instead of other words that may contain the search query?

Upvotes: 0

Views: 263

Answers (1)

Mike Feltman
Mike Feltman

Reputation: 5176

The short answer is you're going to have to call a function to do more advanced searching. I answered a similar question the other day and posted some code that does that here: AngularJS custom search data by writing custom filter it should help you to get started. If you're following the approach taken here you'd probably add a drop down for operator and the modify the function to take into account the operator as well.

Upvotes: 1

Related Questions