In my controller, I want to trigger an action (for example, pressing Tab) only if the form is valid. I also need to clear the form as soon as the form is submitted successfully. I have something like this
app.controller('CommentFormController', function($scope) { $scope.submit = function() { if($scope.commentForm.$valid) {
I would like to check this out, but it looks like I need to create this $scope.contactForm manually and drown the $setPristine() function.
Is there any other way to test this? I mean, can I somehow get an instance of the underlying FormController in my test?
How do you handle such cases?
javascript angularjs validation
grafthez
source share