Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No changes detected on nested fields #258

Closed
mattlewis92 opened this issue Dec 2, 2014 · 2 comments
Closed

No changes detected on nested fields #258

mattlewis92 opened this issue Dec 2, 2014 · 2 comments
Assignees

Comments

@mattlewis92
Copy link

First off, great library, it's easily the best of it's kind and makes working with REST APIs so much easier.

I've noticed that changes on properties that are objects aren't being picked up by the previous() method and consequently the hasChanges() method.

For example I have a user model where the data is:
{name: {first: 'Name'}, email: 'test@fake.com'}

If I change the email property, the functions behave correctly, however if I change name.first, hasChanges() returns false, and previous() returns the modified document.

The bug seems to be caused in the inject method, as the references to the original objects are being saved in the previous attributes. Using angular.copy() to save the previousAttributes appears to do the trick.

The diffObjectFromOldObject method then needs updating to detect changes in objects. Changing:

if (newValue !== oldObject[prop]) {

to

if (!angular.equals(newValue, oldObject[prop])) {

seems to do the trick.

jmdobry added a commit that referenced this issue Dec 2, 2014
Stable Version 1.5.1.
@jmdobry
Copy link
Member

jmdobry commented Dec 2, 2014

Let me know if it's fixed in 1.5.1

@jmdobry jmdobry self-assigned this Dec 2, 2014
@jmdobry jmdobry added the bug label Dec 2, 2014
@mattlewis92
Copy link
Author

That fixed it, thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants