@@ -22,22 +22,10 @@ angular
2222
2323 // watch on route change, then reset some global variables, so that we don't carry over other controller/view validations
2424 $rootScope . $on ( "$routeChangeStart" , function ( event , next , current ) {
25- if ( _globalOptions . resetGlobalOptionsOnRouteChange ) {
26- _globalOptions = {
27- displayOnlyLastErrorMsg : false , // reset the option of displaying only the last error message
28- errorMessageSeparator : ' ' , // separator between each error messages (when multiple errors exist)
29- hideErrorUnderInputs : false , // reset the option of hiding error under element
30- preValidateFormElements : false , // reset the option of pre-validate all form elements, false by default
31- preValidateValidationSummary : true , // reset the option of pre-validate all form elements, false by default
32- isolatedScope : null , // reset used scope on route change
33- scope : null , // reset used scope on route change
34- validateOnEmpty : false , // reset the flag of Validate Always
35- validRequireHowMany : "all" , // how many Validators it needs to pass for the field to become valid, "all" by default
36- resetGlobalOptionsOnRouteChange : true
37- } ;
38- _formElements = [ ] ; // array containing all form elements, valid or invalid
39- _validationSummary = [ ] ; // array containing the list of invalid fields inside a validationSummary
40- }
25+ resetGlobalOptions ( _globalOptions . resetGlobalOptionsOnRouteChange ) ;
26+ } ) ;
27+ $rootScope . $on ( "$stateChangeStart" , function ( event , next , current ) {
28+ resetGlobalOptions ( _globalOptions . resetGlobalOptionsOnRouteChange ) ;
4129 } ) ;
4230
4331 // service constructor
@@ -970,6 +958,28 @@ angular
970958 return new Date ( year , month - 1 , day , hour , min , sec ) ;
971959 }
972960
961+ /** Reset all the available Global Options of Angular-Validation
962+ * @param bool do a Reset?
963+ */
964+ function resetGlobalOptions ( doReset ) {
965+ if ( doReset ) {
966+ _globalOptions = {
967+ displayOnlyLastErrorMsg : false , // reset the option of displaying only the last error message
968+ errorMessageSeparator : ' ' , // separator between each error messages (when multiple errors exist)
969+ hideErrorUnderInputs : false , // reset the option of hiding error under element
970+ preValidateFormElements : false , // reset the option of pre-validate all form elements, false by default
971+ preValidateValidationSummary : true , // reset the option of pre-validate all form elements, false by default
972+ isolatedScope : null , // reset used scope on route change
973+ scope : null , // reset used scope on route change
974+ validateOnEmpty : false , // reset the flag of Validate Always
975+ validRequireHowMany : 'all' , // how many Validators it needs to pass for the field to become valid, "all" by default
976+ resetGlobalOptionsOnRouteChange : true
977+ } ;
978+ _formElements = [ ] ; // array containing all form elements, valid or invalid
979+ _validationSummary = [ ] ; // array containing the list of invalid fields inside a validationSummary
980+ }
981+ }
982+
973983 /** From a date substring split it by a given separator and return a split array
974984 * @param string dateSubStr
975985 * @param string dateSeparator
0 commit comments