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

1

1 Answer 1

1

You can use AngularUI’s ui-validate directive:

<input ui-validate="overallAmount()" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.