I'm using underscore to count object length. _.size(object)
. Because this object is being handled by angularjs there's a $$hashKey
property in the object that's making the length 1 larger than it should be. What's the correct way to count object lengths in angularjs?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Will this do?
_.size(_.omit(object, '$$hashKey'));
Updated
angular.copy()
strips$$hashKey
out for you. So it seems a more Angular way would be_.size(angular.copy(object));
.What about
_.size(angularObject) - 1;
?If this isn't enough, you can of course create your own size function that dosen't count the
$$hashKey
:Example: