How to reset $dirty in form

后端 未结 1 1036
别那么骄傲
别那么骄傲 2021-02-05 01:23

I am facing one issue while using $dirty in my application form.

The issue is once you change the form field,value of $dirty will get s

1条回答
  •  梦毁少年i
    2021-02-05 01:54

    What you are looking for is $setPristine(). You'll find it in the docs here: http://docs.angularjs.org/api/ng/type/form.FormController

    When a form first loads on the page it is in a state called pristine. You'll find that form.$pristine is true and form.$dirty is false. Once any changes have been made to any element that has an Angular binding, those values are reversed. While you can reset the form input values to their original state, doing so does not change either Angular form state. Making a call to form.$setPristine(); sets those form values back to their original state.

    0 讨论(0)
提交回复
热议问题