0

I am trying to have a search box search values in a table. My code currently works fine.

<tr ng-repeat="b in bugs | filter:searchText">

However, I wish to go further and give users the ability to search specific columns if they have a colon in their search text (e.g. "id: 3").

I have managed to split the search text, separating the column name from the field text.

I read in AngularJS you can do searchText.id to filter specific columns. However, my table has quite a few columns and I only have a string of the column name.

My question is, what is the best way to dynamically set the column being filtered?

1 Answer 1

2

Access the column you're searching by accessing it with array syntax.

searchText.id; 
var columnName = "id";
searchText[columnName]; // same thing
Sign up to request clarification or add additional context in comments.

Comments

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.