-
Notifications
You must be signed in to change notification settings - Fork 27.4k
in 1.3.16 ng-repeat filter changed from not filtering the absent fields to filtering them #12060
Comments
There is nothing in 1.3.16 that should affect |
Hi, Thanks for the fast response. As you have mentioned the problem was from the change in the "filter filter" implementation. In 1.3.15, if the filter object values are absent in the data, the data passes through ng-repeat. In 1.3.16, if the filter object values are absent in the data, the data is not passed from ng-repeat Check the plunker: http://plnkr.co/edit/5WSyJIlnxRmwkY8wk590?p=preview |
If you need to put a value on a filter so it gets ignored, then it should be set to |
No no. Have you checked the plunker I send? To make it more discrete I am outlining a usage scenario:
|
@ali-bugdayci, this is unfortunately how In cases where you want to avoid an emty search field resulting in case-insensitive substring comparison against |
@gkalpak If you are aware that it works like this and ok with it, than I have nothing to say. But from my users point of view I believe the scenario I described is not acceptable. Seems like I will be sticking with 1.3.15 for a long time. |
This is has come up a few times and we (I) are aware of this. I don't say I am against changing it, but it will be a breaking change. I am definitely open to discussion, though. Luckily, Angular is too flexible for you to have to stick to
(Especially for a large project, the overhead should be minimal 😃) |
@gkalpak Yeah you are right. May be the best way would be to configure the filterFilter with a filterprovider and choose how you want it to behave. |
@ali-bugdayci, what would that filterProvider allow you to do which isn't already possible ? Do you mean something like offering a config flag to enable ignoring empty strings ? BTW, there is no such thing as "provider" for filters, but we might be able to attach some properties on the filter itself. |
@gkalpak yeah I know that we dont have filter provider, but you got what I meant. Instead of every one trying to solve this problem, configuring it through a flag option would be awesome. But I wouldn't expect something fast. Since you guys are aware of this problem, and made your choice, this would not be a high priority issue. |
There is no configuration phase (unlike standard services) for filters and for this use case it would be an unrealistic change to the core. Also changing how a filter behaves across the board and behind the scenes is a recipe for disaster. If you are using a third party component that expects As @gkalpak points out there are a number of extension points in Angular to allow you to achieve the effect you wish. Here are a couple of examples:
The second option is perhaps the recommended approach as it doesn't mess with the model value. By attaching the comparator to the |
@petebacondarwin said it all. I just wanted to add that (especially for a large project using the same behaviour in many places), another viable option is to define a custom filter that wraps Or (depending on how you construct filtering predicates, creating a directive that converts empty strings to |
in 1.3.15 we have working code like this:
where the ng-view included can see and use the vm object.
Update to 1.3.16 breaks this and ng-view creates a new scope object. Hence the vm used inside the included code is not same object.
The text was updated successfully, but these errors were encountered: