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

How to apply the directive AFTER data is loaded through HTTP? #46

Open
samlevin opened this issue Jul 27, 2015 · 4 comments
Open

How to apply the directive AFTER data is loaded through HTTP? #46

samlevin opened this issue Jul 27, 2015 · 4 comments

Comments

@samlevin
Copy link

Any time I add values to a form (that are loaded through HTTP), this library always thinks my form is dirty. Any easy workaround? I want the dirty check to start taking place only after a form is initialized.

Thanks a ton for your quick guidance.

@cstephe
Copy link

cstephe commented Jul 27, 2015

Can you post how you are loading data. Form dirty normally doesn't get set unless you are triggering user events.

@samlevin
Copy link
Author

Basically making a call to an HTTP service, which returns an object (in a predetermined format), and then I bind that object to scope in a controller. The UI template uses this controller, and I'm using 'ng-model' (on the $scope object properties) to display the object properties in the UI

EDIT: After I load the controller/template with the form, the log states 'all forms are clean'. However, when I try to click another object (which loads a new form), I then get a log message stating 'a form is dirty', even after I've made 0 clicks on the UI (aside from opening up a new form).

@samlevin
Copy link
Author

It seems like $pristine() is called after the directive loads, but before the HTTP call has finished.

@awerlang
Copy link

Make sure your form is in $pristine state while it is loading data. Perhaps a specific control your are using is setting your form as $dirty.

It may help to pinpoint the exact source of error if you put a breakpoint on $setDirty() to see who is calling that.

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

No branches or pull requests

3 participants