-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Implement filtering on object-based ng-repeat #6490
Comments
+1 |
+1 |
+1 nice to have!
|
@gkalpak Been a while since I looked at this code :) what would you like changed in regards to the tests? |
@3lux: Not really sure :) It's more of a fuzzy feeling. I sure don't like the "obscure" helpers (maybe just because I don't get their usefulness). I had left some inline comments the other day. |
Would be a cast to array on the
|
+1 |
1 similar comment
+1 |
this looks like a perfect solution for a third-party module. BTW, just by adding https://github.com/petebacondarwin/angular-toArrayFilter you can do and more |
👍 |
WE've decided that the filterFilter should only work on arrays. It'll throw in 1.4 and beyond if it is passed an object, see cea8e75 |
@Narretz - throwing an error will help newbies a lot, as it indicates unintended use straightaway instead of wondering at some later point in time why it doesn't work as expected.
Could you maybe shed some light on the arguments behind this decision, so us "consumers" can embrace it better and understand why it makes sense not to have an object-based ng-repeat filter? |
It's been discussed in several places/issues, but I believe #2694 (comment) sums it up nicely. Basically, it's not something that can be done reliably and without loss of information and the usecase shouldn't be common (plus it can be very easily implemented as a 3rd-party module and not contribute to the size of the core). |
Currently if you are using the ng-repeat directive to walk over the properties of a non-array object, filters will not work as they test immediately if the collection is an array and reject anything not matching.
This behavior can be seen here:
angular.js/src/ng/filter/filter.js
Line 118 in 06f2ba8
This is an undocumented and - per #6215 - potentially unwanted behavior, since the syntax is the same for iterating over arrays and objects. Plus, it's just darn useful!
Opening up the lines of discussion here to see if it's worth implementing filter functionality for objects and not just straight array/array-like structures.
The text was updated successfully, but these errors were encountered: