I'm wondering how to build a custom filter in AngularJS that filters by ID.
Lets say you have comments, and every comment got a property.
A. 1
B. 2
C. 1-1
D. 3
E. 1-2
F. 1-1-1
I would like to have it filtered to
A. 1
B. 1-1
C. 1-1-1
D. 1-2
E. 2
F. 3
Created a plnkr: http://plnkr.co/edit/JdqFD3sQuxSkipZoIWX4?p=preview
You mean sorted via the filter. You can use the orderBy
filter with a custom expression
<li ng-repeat="x in comments | orderBy:'ID'">...</li>
Here is the updated plunkr http://plnkr.co/edit/Jf3I5ykHBqN6hl4kc5Q4?p=preview