1

So I have a table that is programmatically created and I want to apply a custom filter to only one of the fields. I've created a plunkr here:

http://plnkr.co/edit/57rEPEYNylisoHyBysp4

So by applying the filter to the Age column, the table would return:

Name    Age
Enos    I'm a number greater than 30: 34
Moroni  I'm a number greater than 30: 50
Jacob   I'm a number less than 30: 27
Nephi   I'm a number less than 30: 29
Enos    I'm a number greater than 30: 34
Tiancum I'm a number greater than 30: 43
Jacob   I'm a number less than 30: 27
Nephi   I'm a number less than 30: 29
Tiancum I'm a number greater than 30: 43
Tiancum I'm a number greater than 30: 43

I've tried:

<td ng-repeat="column in columns | filter:{ age: numCheck }" ng-show="column.visible" sortable="column.field">
                {{user[column.field]}}
</td>

Among other things in the HTML. I've also tried changing the getData function in the controller to no avail.

Is it possible to do this?

Best Regards, Julie

EDIT So I created this plunkr which is closer to what I want to do in real life (based on Explosion's answer below):

http://plnkr.co/edit/pynm57tlQK53bCKbQjht

1 Answer 1

1

| filter uses the filter filter, which is something different. Instead, you want to apply the filter you created to the string you are displaying:

{{user[column.field] | numCheck}}

Of course you will need to do an additional check on whether you actually want to apply the filter or not. There are a lot of ways to do this, but with the way you currently have everything set up I think the simplest would just be to check whether the value passed to numCheck is a number or not.

Sign up to request clarification or add additional context in comments.

1 Comment

Okay, so I had gotten that far and was thinking I could specify the field somehow. But I have figured out how to do what I want, so thanks Explosion!!

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.