@@ -51,9 +51,17 @@ angular.module('bootstrap.angular.validation').directive('form', [
5151 delete $formAttributes . ngSubmit ;
5252
5353 var preLinkFunction = function ( $scope , formElement , $attr , formController ) {
54- // Expose a method to manually trigger the validation
55- formController . $validate = function ( ) {
54+ // Expose a method to manually show the validation state
55+ formController . $showValidation = function ( ) {
5656 formController . $setSubmitted ( ) ;
57+ // Tell form elements to show validation state
58+ $scope . $broadcast ( 'onBsValidationStateChange' , { showValidationState : true } ) ;
59+ } ;
60+
61+ formController . $hideValidation = function ( ) {
62+ formController . $setPristine ( ) ;
63+ // Tell form elements to hide validation state
64+ $scope . $broadcast ( 'onBsValidationStateChange' , { showValidationState : false } ) ;
5765 } ;
5866
5967 formElement . on ( 'submit' , function ( e ) {
@@ -78,12 +86,12 @@ angular.module('bootstrap.angular.validation').directive('form', [
7886 * Do not show validation errors once the form gets submitted. You can still display the
7987 * validation errors after form submission by calling '$setSubmitted' in your form controller.
8088 */
81- formController . $setPristine ( ) ;
89+ formController . $hideValidationState ( ) ;
8290 } ) ;
8391
8492 /**
8593 * Prevent other submit event listener registered via Angular so that we can mark the form with
86- * the prestine state. Otherwise, that Angular's listener is getting called at the last and is again
94+ * the pristine state. Otherwise, that Angular's listener is getting called at the last and is again
8795 * setting form to the submitted.
8896 *
8997 * https://api.jquery.com/event.stopimmediatepropagation/
0 commit comments