Determines the number of elements in an array, number of properties of an object or string length.
Note: this function is used to augment the Object type in angular expressions. See
angular.Object
for more info.
angular.Object.size(obj, ownPropsOnly);
obj – {Object|Array|string} –
Object, array or string to inspect.
ownPropsOnly – {boolean} –
Count only "own" properties in an object
{number}
– The size of obj
or 0
if obj
is neither an object or an array.
Number of items in array: {{ [1,2].$size() }}<br/> Number of items in object: {{ {a:1, b:2, c:3}.$size() }}<br/>
it('should print correct sizes for an array and an object', function() { expect(binding('[1,2].$size()')).toBe('2'); expect(binding('{a:1, b:2, c:3}.$size()')).toBe('3'); });