My goal is to implement a $watch in order to verify the validity of a form input.
// customCtrl.html
....
<div class="row" ng-form="customCtrl.customForm">
...
<div class="form-group">
<label>ADDRESS</label>
<input
class="form-control"
id="address"
type="text"
ng-model="customCtrl.customEdit.address">
</div>
...
// customCtrl.js
...
class CustomController {
constructor($scope,
...
) {
...
}
...
canSaveCustom() {
return this.customForm.$valid;
}
...
I would like to set up a watcher using the following approach:
$scope.$watch('customForm.$invalid', function(isInvalid) {
$scope.disableSubmitBtn = isInvalid;
});
However, I am uncertain about where exactly in the code base I should insert this watcher.