forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.Object.size.html
31 lines (30 loc) · 1.28 KB
/
angular.Object.size.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<h1>angular.Object.size</h1>
<div class="angular-object-size"><h2>Description</h2>
<div class="description"><p>Determines the number of elements in an array or number of properties of an object.</p>
<p>Note: this function is used to augment the Object type in angular expressions. See
<a href="#!angular.Object"><code>angular.Object</code></a> for more info.</p></div>
<h2>Usage</h2>
<div class="usage"><div ng:non-bindable=""><pre class="brush: js; html-script: true;">angular.Object.size(obj);</pre>
</div>
<h3>Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">obj – {Object|Array} – </code>
<p>Object or array to inspect.</p></li>
</ul>
<h3>Returns</h3>
<div class="returns"><code ng:non-bindable="">{number}</code>
– <p>The size of <code>obj</code> or <code>0</code> if <code>obj</code> is neither an object or an array.</p></div>
</div>
<h2>Example</h2>
<div class="example"><doc:example>
<doc:source>
Number of items in array: {{ [1,2].$size() }}<br/>
Number of items in object: {{ {a:1, b:2, c:3}.$size() }}<br/>
</doc:source>
<doc:scenario>
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');
});
</doc:scenario>
</doc:example></div>
</div>