my check boxes run a function with operates several tasks to manipulate the model programmatically and this seems to not allow the form to become dirty.
on the basis my form is named "testForm" how would I include a reference in my existing function to set the form to be dirty when that checkbox calls it on click?
do I need to reference the forms name or is it a case of setting the model to be dirty such as
$scope.$dirty = true;
You should use the markAsDirty method, like this: control. markAsDirty(); This will also mark all direct ancestors as dirty to maintain the model.
$setPristine();Sets the form to its pristine state. This method sets the form's $pristine state to true, the $dirty state to false, removes the ng-dirty class and adds the ng-pristine class.
When the user changes the value in the watched field, the control is marked as "dirty" When the user blurs the form control element, the control is marked as "touched"
ng-dirty: The ng-dirty class tells that the form has been made dirty (modified ) by the user. It returns true if the user has modified the form. Return type: Return Boolean True if the form/input field is modified by the user else it returns False.
$form.$setDirty();
$form.email.$dirty = true;
Here, $form = form.
email = field name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With