forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.Object.equals.html
52 lines (46 loc) · 2.32 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
<h1>angular.Object.equals</h1>
<div class="angular-object-equals"><h2>Description</h2>
<div class="description"><p>Determines if two objects or value are equivalent.</p>
<p>To be equivalent, they must pass <code>==</code> comparison or be of the same type and have all their
properties pass <code>==</code> comparison. During property comparision properties of <code>function</code> type and
properties with name starting with <code>$</code> are ignored.</p>
<p>Supports values types, arrays and objects.</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.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>
<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>
</doc:source>
<doc:scenario>
it('should print that initialy greeting is equal to the hardcoded value object', function() {
expect(element('.doc-example input[name=greeting.salutation]').val()).toBe('Hello');
expect(element('.doc-example input[name=greeting.name]').val()).toBe('world');
expect(element('.doc-example 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 span').css('display')).toBe('inline');
});
</doc:scenario>
</doc:example></div>
</div>