I\'ve created a validation directive for my form. It basically validates a fields value based on data from another field.
It works perfect :-)
My problem is
Maybe a simpler solution would be with a watcher or even an expression inside the ng-show direcive of your error span.
Using an expression inside the ng-show directive would be like this:
Otherwise you could watch for changes in the models int1 and int2 and compare their values:
$scope.$watch('int1+int2', function () {
if($scope.int1 > $scope.int2) {
$scope.error = true;
}else {
$scope.error = false;
}
})
Here is a fiddle