forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.Object.equals.html
57 lines (50 loc) · 2.52 KB
/
angular.Object.equals.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<h1>angular.Object.equals</h1>
<div class="angular-object-equals"><h2>Description</h2>
<div class="description"><p>Determines if two objects or two values are equivalent. Supports value types, arrays and
objects.</p>
<p>Two objects or values are considered equivalent if at least one of the following is true:</p>
<ul>
<li>Both objects or values pass <code>===</code> comparison.</li>
<li>Both objects or values are of the same type and all of their properties pass <code>===</code> comparison.</li>
</ul>
<p>During a property comparision, properties of <code>function</code> type and properties with names
that begin with <code>$</code> are ignored.</p>
<p>Note: This function is used to augment the Object type in Angular expressions. See
<a href="#!/api/angular.Array"><code>angular.Array</code></a> for more information about Angular arrays.</p></div>
<h2>Usage</h2>
<div class="usage"><div ng:non-bindable=""><pre class="brush: js; html-script: true;">angular.Object.equals(o1, o2);</pre>
</div>
<h3>Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">o1 – {*} – </code>
<p>Object or value to compare.</p></li>
<li><code ng:non-bindable="">o2 – {*} – </code>
<p>Object or value to compare.</p></li>
</ul>
<h3>Returns</h3>
<div class="returns"><code ng:non-bindable="">{boolean}</code>
– <p>True if arguments are equal.</p></div>
</div>
<h2>Example</h2>
<div class="example"><doc:example>
<pre class="doc-source">
Salutation: <input type="text" name="greeting.salutation" value="Hello" /><br/>
Name: <input type="text" name="greeting.name" value="world"/><br/>
<hr/>
The <code>greeting</code> object is
<span ng:hide="greeting.$equals({salutation:'Hello', name:'world'})">NOT</span> equal to
<code>{salutation:'Hello', name:'world'}</code>.
<pre>greeting={{greeting}}</pre>
</pre>
<pre class="doc-scenario">
it('should print that initialy greeting is equal to the hardcoded value object', function() {
expect(element('.doc-example-live input[name=greeting.salutation]').val()).toBe('Hello');
expect(element('.doc-example-live input[name=greeting.name]').val()).toBe('world');
expect(element('.doc-example-live span').css('display')).toBe('none');
});
it('should say that the objects are not equal when the form is modified', function() {
input('greeting.name').enter('kitty');
expect(element('.doc-example-live span').css('display')).toBe('inline');
});
</pre>
</doc:example></div>
</div>