0

I have a method in my angular controller that returns true or false.

$scope.overallAmount = function () {
            var cnt = $scope.orders.length, sum = 0;
            while (cnt--) 
                sum += parseFloat(($scope.orders[cnt].CardAmount || 0) * ($scope.orders[cnt].Quantity || 0)) || 0;
            return (500 - sum) > 0;
        };

I'd like to use this for validation. Is it possible to create custom validation that just uses a scope method's true or false to validate? A snippet would be helpful, thanks

Proximo
  • 6,235
  • 11
  • 49
  • 67
  • [How to add custom validation to an AngularJS form?](https://stackoverflow.com/q/12581439/6521116) – LF00 Nov 14 '17 at 08:22

1 Answers1

1

You can use AngularUI’s ui-validate directive:

<input ui-validate="overallAmount()" />
Phú
  • 48
  • 8