I have the following code in my HTML page:
<input type="text" name="dns" class="form-control ng-valid" ng-model="conf['dns']" ng-list="">
When I type something in the text field, its changed to:
<input type="text" name="dns" class="form-control ng-valid ng-dirty" ng-model="conf['dns']" ng-list="">
I wish to check if the field its dirty, and do some acts if so. I have the following:
Controller.controller('CuController',
function($scope, $location, $modal, Controller) {
console.log($scope.conf['dns']) //prints the value of this field
// Wish to check if $scope.conf['dns'] is dirty
})
I try to use $scope.conf[dns].$dirty, but it returns undefined.
How can I check if the field is dirty (Meaning that the value of the field was changed)?
$dirty is a parameter of the input of your form, try $scope.yourForm.dns.$dirty
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