Skip to content

Commit 9f351f1

Browse files
committed
Autobind: fix bug with pushing and splicing objects from array
1 parent e504c2c commit 9f351f1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

modules/ngMeteor-collections.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ ngMeteorCollections.factory('$collection', ['$q', 'HashKeyCopier',
4343
// Remove items that don't exist in the collection anymore.
4444
angular.forEach(oldItems, function (oldItem) {
4545
var index = newItems.map(function (item) {
46-
return item._id._str;
47-
}).indexOf(oldItem._id._str);
48-
if (index == -1) newItems.remove(oldItem._id);
46+
return item._id;
47+
}).indexOf(oldItem._id);
48+
if (index == -1) { // To here get all objects that pushed or spliced
49+
if (oldItem._id) { // This is a check to get only the spliced objects
50+
newItems.remove(oldItem._id);
51+
}
52+
}
4953
});
5054
newItems.save(); // Saves all items.
5155
}, auto);
5256
}
5357
}
54-
58+
5559
};
5660
}
5761
}

0 commit comments

Comments
 (0)