-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Angularjs 1.1.5: ngRepeat not filtering correctly[UPDATE] #2797
Comments
looks like your links / code examples disappeared |
I just updated :) |
|
Sorry about that, I updated the example. This is still not working with the == Thanks! |
+1 for this. This doesn't work for me at least in v1.1.5 and v1.1.6. Looks to be an App.controller('Todo', ['$scope', 'filterFilter', function($scope, filter) {
var todos = [
{ title: 'One', completed: true },
{ title: 'Two', completed: false },
{ title: 'Three', completed: false },
{ title: 'Four', completed: false }
];
var active = filter(todos, { completed: false }).length;
console.log('active:', active); // outputs 4 instead of 3 active items
}]); Can someone confirm this or we are doing something wrong? Thanks. |
Think i've found the issue and fix for it. if (!expression[key]) return; and should be: if (typeof(expression[key]) === undefined) { return; }
// or
if (!expression.hasOwnProperty(key)) { return; }
// or
if (!(key in expression)) { return; } Thanks. |
+1 for this. |
+1 for this too |
+1 for this fix as well. In the meantime, there is a handy tip from revolunet that will make filtering for falsey values a little easier: $scope.isFalsey = function(val) {
return !val;
}
|
Code was evaluating !expression[key] while attempting to see if the key was present, but this was evaluating to true for false values as well as missing keys. Closes angular#2797.
Will this be fixed in angularJS 1.2? I tried filtering false property in angularjs 1.2.0-rc.3 but with no luck. Here is fiddle to test it: |
You can see what works in different angular versions here: http://jsfiddle.net/f38zB/ Seems versions 1.1.3 to 1.2.0rc1 are most buggy. Version 1.2.0rc1 adds another bug into the fray. Versions 1.2.0rc2 and 1.2.0rc3 seem to work correctly using the object syntax. No version since 1.1.2 correctly handles the syntax given in the original example. |
Cool thanks, object syntax worked :) |
Hi,
The unstable version of Angularjs 1.1.5 is not filtering on attributes with value set to false.
Try this code as an example:
If you change the Angularjs reference to the stable version 1.0.7 the filters work fine.
Is this a bug or am I doing something wrong?
Thanks
The text was updated successfully, but these errors were encountered: