This repository has been archived by the owner on Jul 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
IsErrorMessageVisible
Ghislain B edited this page Jan 19, 2017
·
4 revisions
version 1.5.15+
In some cases, you might to know if the error message is shown or not and depending on that do other things. Thanks to the user @Gusi you can now do it in a simple way. A new flag isErrorMessageVisible
was created for that usage, see below for a use case.
(function() {
var bootstrapValidationDecorator = function() {
return {
scope: {
bootstrapValidationDecorator:'@'
},
restrict: 'A',
require: '^form',
link: function (scope, el, attrs, formCtrl) {
scope.form = formCtrl; // no template so no need for that for now
console.log(scope.form);
if(scope.bootstrapValidationDecorator!=undefined && scope.bootstrapValidationDecorator!="") {
scope.fieldName = scope.bootstrapValidationDecorator;
} else {
scope.fieldName = angular.element( el[0].querySelector("[name]") ).attr('name');
}
scope.$watch(
function(scope) {
return scope.form[scope.fieldName].isErrorMessageVisible; // NEW
},
function( newVal, oldVal ) {
if(newVal != oldVal){
el.toggleClass('has-error', newVal === true); // NEW
}
}
);
}
}
}
angular.module('app').directive('bootstrapValidationDecorator', bootstrapValidationDecorator);
}());
Contents
- Angular-Validation Wiki
- Installation
- Demo
- Code Samples
- Functionalities
- Custom Validations
- Properties & Options
- Validators
- Tests
- Misc