0

When my form loads initially the $pristine property is always false. It was my understanding that as long as there's no user interaction with the form that the $pristine property will be true until the user changes the model via some kind of interaction. Is there anything else that I need to be aware that could set the $pristine property to false without the user manually changing the model? I'm trying to alert the user that there are unsaved changes before they close the form if it's not pristine.

5
  • When the form loads, form.$pristine === true: plnkr.co/edit/mPTSfly5juSYi5RmcMwi?p=preview Commented Feb 11, 2015 at 17:52
  • 1
    use form.$dirty instead of form.$pristine to check for user changes Commented Feb 11, 2015 at 17:55
  • I've tried form.$dirty but it is always true when the form loads. Do you know what could cause this property to be set to false other than user interaction with the form? Commented Feb 11, 2015 at 18:04
  • 1
    @wbeange, $dirty is always !$pristine. Your comment is misleading Commented Feb 11, 2015 at 18:07
  • @nweg, as I showed in the plunker in my first comment - form is $pristine when it loads. Something else is going on, so you need to edit your question and show more code Commented Feb 11, 2015 at 18:10

1 Answer 1

1

The problem ended up being the use of the Select2 angularjs directive. There's a known bug that causes the form to be dirty on initialization. There's currently an open issue on github that covers this problem. Issue Here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.