Skip to content

Instantly share code, notes, and snippets.

@enapupe
Created November 6, 2014 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enapupe/38fa9aa4d88aa30d3dfa to your computer and use it in GitHub Desktop.
Save enapupe/38fa9aa4d88aa30d3dfa to your computer and use it in GitHub Desktop.
AngularJS auto $setPristine() on reset
angular.module("myApp").directive("form", function(){
return {
require: "^form",
link: function(scope, elem, attr, ctrl){
elem.on("reset", function(){
ctrl.$setPristine();
});
}
};
});
@enapupe
Copy link
Author

enapupe commented Nov 6, 2014

this directive triggers $setPristine() when the form receives reset event (via <input type="reset">, etc)

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