The ng-dirty
class tells you that the form has been modified by the user, whereas the ng-pristine
class tells you that the form has not been modified by the user. So ng-dirty
and ng-pristine
are two sides of the same story.
The classes are set on any field, while the form has two properties, $dirty
and $pristine
.
You can use the $scope.form.$setPristine()
function to reset a form to pristine state (please note that this is an AngularJS 1.1.x feature).
If you want a $scope.form.$setPristine()
-ish behavior even in 1.0.x branch of AngularJS, you need to roll your own solution (some pretty good ones can be found here). Basically, this means iterating over all form fields and setting their $dirty
flag to false
.
Hope this helps.
Related Posts:
- typeerror cannot read property ‘data’ of undefined
- nodemon app crashed – waiting for file changes before starting
- Refused to display in a frame because it set ‘X-Frame-Options’ to ‘SAMEORIGIN’
- Refused to display in a frame because it set ‘X-Frame-Options’ to ‘SAMEORIGIN’
- How to format date in angularjs
- Angular-ui-router: ui-sref-active and nested states
- Unable to resolve dependency tree error when installing npm packages
- Understanding STATE in angularJS
- What is .$on() in AngularJS
- Significance of ng-repeat-start vs ng-repeat
- File Upload using AngularJS
- AngularJS : Prevent error $digest already in progress when calling $scope.$apply()
- AngularJS BootstrapUI Typeahead with object & selection functionality
- angular.service vs angular.factory
- How do I store data in local storage using Angularjs?
- What is .$on() in AngularJS
- `ui-router` $stateParams vs. $state.params
- Simple Popup by using Angular JS
- $apply already in progress error
- Why do i have to call $scope.$digest() here?
- ng-repeat :filter by single field
- What is deep linking in AngularJS?
- Difference between onLoad and ng-init in angular
- How do I fix the npm UNMET PEER DEPENDENCY warning?
- Submit form on pressing Enter with AngularJS
- How to $state.go()
- AngularJS ng-disabled directive with expression is not working
- With ng-bind-html-unsafe removed, how do I inject HTML?
- How to filter a select with ng-options in Angular?
- What is the use of angular ui-mask?
- Response for preflight has invalid HTTP status code 403 on angular post request
- How to achieve pagination/table layout with Angular.js?
- Angular js is front end or backend?
- AngularJS Folder Structure
- Bare minimum code for AngularJS Carousel
- AngularJS $watch vs $watchCollection: which is better for performance?
- Angular.js: How does $eval work and why is it different from vanilla eval?
- angular.element vs document.getElementById or jQuery selector with spin (busy) control
- Angularjs ng-view does not work
- getting the ng-object selected with ng-change
- AngularJS For Loop with Numbers & Ranges
- Why is .then not a function?
- How do I filter an array with AngularJS and use a property of the filtered object as the ng-model attribute?
- AngularJS Modal Popup
- Why do we use $rootScope.$broadcast in AngularJS?
- how to use ng-option to set default value of select element
- What does ngInject do in the following piece of code?
- AngularJS: how to implement a simple file upload with multipart form?
- How to get all place details from a Place Details Request using Google Places API Web Service?
- AngularJS vs Angular [closed]
- SyntaxError: Unexpected token o in JSON at position 1
- SyntaxError: Unexpected token o in JSON at position 1
- SyntaxError: Unexpected token o in JSON at position 1
- SyntaxError: Unexpected token o in JSON at position 1
- AngularJS- Login and Authentication in each route and controller
- TypeError: Cannot read property ‘then’ of undefined
- How to Create simple drag and Drop in angularjs
- Working with $scope.$emit and $scope.$on
- In angularjs we are having ng-disabled directive, why ng-enabled directive is not provided by the framework as we are having ng-show and ng-hide
- Regular expression : match either of two conditions?
- SyntaxError: Unexpected token o in JSON at position 1
- AngularJS : Factory and Service?
- AngularJS ngClass conditional
- Give a value to an ng-model=”searchText” input based on list item clicked in Angular JS
- TypeError: Cannot read property ‘get’ of undefined on AngularJS
- Blocked script execution in because the document’s frame is sandboxed – Angular application
- Angular JS Uncaught Error: [$injector:modulerr]
- How to set the id attribute of a HTML element dynamically with angularjs (1.x)?
- Using $setValidity inside a Controller
- How can I group data with an Angular filter?
- Failed to load resource: the server responded with a status of 401 (Unauthorized) /App/AngularJS/angular.min.js
- Definition of ui-sref in Angular.js?
- Angular: Cannot find a differ supporting object ‘[object Object]’
- Error: ENOENT: no such file or directory, stat ‘/public/main.html’ at Error (native)
- Disable Chrome strict MIME type checking
- Angularjs: Error: [ng:areq] Argument ‘HomeController’ is not a function, got undefined
- Show spinner GIF during an $http request in AngularJS?
- SyntaxError: expected expression, got ‘<'
- Understanding the ngRepeat ‘track by’ expression
- How to pass parameters using ui-sref in ui-router to controller
- What does ngf-select do and why is it needed for form validation?
- Is Angularjs Clientside or Serverside or Both
- How to connect signalR from angularJs
- How does Angular $q.when work?
- Array Mapping in AngularJs
- AngularJS errors: Blocked loading resource from url not allowed by $sceDelegate policy
- How to use if-else condition with [ngClass] in angular 7?
- How do you serve a file for download with AngularJS or Javascript?
- Failed to execute ‘postMessage’ on ‘DOMWindow’: https://www.youtube.com !== http://localhost:9000
- How to redirect to another page using AngularJS?
- How npm start runs a server on port 8000
- Why is this simple AngularJS ng-show not working?
- How do I bind to list of checkbox values with AngularJS?
- parsing JSONP $http.jsonp() response in angular.js
- AngularJS POST Fails: Response for preflight has invalid HTTP status code 404
- What is the cause for “angular is not defined”
- $http.get(…).success is not a function
- Unexpected token < in first line of HTML
- ngular is automatically adding ‘ng-invalid’ class on ‘required’ fields
- if else statement in AngularJS templates