Skip to content

Commit 4c7de37

Browse files
committed
Fixed using display preference from the element itself. #9
1 parent 44da625 commit 4c7de37

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

dist/bootstrap-angular-validation.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/tooltip.message.service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
'use strict';
44

5-
angular.module('bootstrap.angular.validation').factory('tooltipMessageService', ['$uibPosition', 'BsValidationService',
6-
function($uibPosition, validationService) {
5+
angular.module('bootstrap.angular.validation').factory('tooltipMessageService', ['$injector', 'BsValidationService',
6+
function($injector, validationService) {
77

88
var iconMarkup = '<i class="fa fa-exclamation-triangle fa-fw"></i>';
99

@@ -38,7 +38,7 @@ function($uibPosition, validationService) {
3838
return validationService.resolveMessage($element, $attr, key);
3939
},
4040

41-
showErrorMessage: function($element, $attr, ngModelController, $formGroupElement) {
41+
showErrorMessage: function($element, $attr, ngModelController) {
4242
var firstErrorKey = Object.keys(ngModelController.$error)[0];
4343
var message = this.resolveMessage($element, $attr, firstErrorKey);
4444

@@ -52,7 +52,7 @@ function($uibPosition, validationService) {
5252
$errorTooltip = getErrorTooltip($element);
5353
}
5454

55-
var ttPosition = $uibPosition.positionElements($element, $errorTooltip, 'bottom-left', true);
55+
var ttPosition = $injector.get('$uibPosition').positionElements($element, $errorTooltip, 'bottom-left', true);
5656
$errorTooltip.css({ top: ttPosition.top + 'px', left: ttPosition.left + 'px' });
5757
$errorTooltip.findOne('.tooltip-inner').html(message);
5858
$errorTooltip.addClass('in').addClass(ttPosition.placement);

src/services/validation.service.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,19 @@ angular.module('bootstrap.angular.validation').factory('BsValidationService', ['
130130
},
131131

132132
displayErrorPreference: function($element, $attr) {
133-
if ($attr[displayErrorAsAttrName]) {
134-
return $attr[displayErrorAsAttrName];
133+
var attrName = displayErrorAsAttrName;
134+
if ($attr[attrName]) {
135+
return $attr[attrName];
135136
} else {
136137
var $parentForm = $element.parents('form');
137138

138139
// .attr() method not accepting camelCase version of the attribute name. Converting it to dashed-case
139-
displayErrorAsAttrName = displayErrorAsAttrName.replace(/([A-Z])/g, function($1) {
140+
attrName = attrName.replace(/([A-Z])/g, function($1) {
140141
return '-' + $1.toLowerCase();
141142
});
142143

143-
if ($parentForm && $parentForm.attr(displayErrorAsAttrName)) {
144-
return $parentForm.attr(displayErrorAsAttrName);
144+
if ($parentForm && $parentForm.attr(attrName)) {
145+
return $parentForm.attr(attrName);
145146
}
146147
}
147148

0 commit comments

Comments
 (0)