Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs counting object length

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?

like image 672
Harry Avatar asked Jun 30 '26 22:06

Harry


1 Answers

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));.

like image 99
Brian Lewis Avatar answered Jul 02 '26 10:07

Brian Lewis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!