Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

moment.js and scope.$watch when objectEquality is true #4996

Closed
@danielgatis

Description

@danielgatis

Hi,
I have a object that have a moment.js property like this:

obj = { date: moment(), status: 'ok' }

so if i watch this object with objectEquality like this:

scope.$watch('obj', ..., true); 

i get this errors:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

To fix this i need to override angular.equals function to compare momentjs objects correctly.

function equals(o1, o2) {
  /* patch for moment */
  if (moment.isMoment(o1) && o1.toString() === o2.toString()) return true;
...
}

What is the best way to do this?

thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions