angular.Object.equals

Description

Determines if two objects or value are equivalent.

To be equivalent, they must pass == comparison or be of the same type and have all their properties pass == comparison. During property comparision properties of function type and properties with name starting with $ are ignored.

Supports values types, arrays and objects.

Note: this function is used to augment the Object type in angular expressions. See angular.Object for more info.

Usage

angular.Object.equals(o1, o2);

Parameters

Returns

{boolean}

True if arguments are equal.

Example

    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>
    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');
    });