I'm attempting to observe the $error
or $valid
status of a control. Here is the control in question:
<form id="myForm" name="myForm">
<input name="myInput" ng-model="myInputMdl" business-validation/>
</form>
The business-validation
directive customizes the validity of the control. I have tried various methods (using either $valid
or $error
) based on suggestions from this source:
This method does not work as there is no
$valid
property onmyForm.myInput
.$scope.$watch('myForm.myInput.$valid', function(isValid) { $scope.usefulVariable = step3.CreditCardNumber.$valid; }, true);
This approach fails because
validity.valid
cannot be watched.$scope.$watch('myForm.myInput.validity.valid', function(isValid) { $scope.usefulVariable = step3.CreditCardNumber.$valid; }, true);
This strategy doesn't work as
$scope.myInputMdl
is not being monitored for changes.$scope.$watch('$scope.myInputMdl', function(isValid) { $scope.usefulVariable = step3.CreditCardNumber.$valid; }, true);
Is it possible to watch the validity from a controller?
EDIT
I am not seeking to modify the business-validation
directive. My goal is to monitor $valid
or $error
from the form's controller.
EDIT 2
The code for the controller is as follows:
app.controller('WizardBusinessActionCtrl',
function($scope, $http, $parse, $filter, wizardBusinessActionService, $timeout) {
//controller code
}
);