angularjs计数对象长度 [英] angularjs counting object length

查看:314
本文介绍了angularjs计数对象长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下划线来算对象长度。 _。尺寸(对象)。因为这个对象是由angularjs处理有一个在该对象的 $$ hashKey 属性,它的制作长度1大于它应该是。什么是计数angularjs对象长度的正确方法是什么?

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?

推荐答案

这是否会做什么? _尺寸(_省略(对象,'$$ hashKey'));

更新

angular.copy() $$ hashKey 为你。因此,它似乎是一种更角的方法是 _大小(angular.copy(对象));

angular.copy() strips $$hashKey out for you. So it seems a more Angular way would be _.size(angular.copy(object));.

这篇关于angularjs计数对象长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆