From 6a99b08e2987bf92e96554b75107845e5e714bb9 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lenglet Date: Wed, 17 Feb 2016 11:15:06 +0100 Subject: [PATCH] fix: Allow setting a ngClass on element Since a ngClass is already present in the uiSelect theme templates, we could not add any ngClass on without getting an JS error Currently, adding a ngClass on result in: `ng-class="{class: expression} {open: $select.open}"` With this fix, doing the same thing result in: `ng-class="{class: expression, open: $select.open}"` Closes #277 --- src/uiSelectDirective.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/uiSelectDirective.js b/src/uiSelectDirective.js index 4be1ff34c..3f5bbffc8 100644 --- a/src/uiSelectDirective.js +++ b/src/uiSelectDirective.js @@ -17,6 +17,14 @@ uis.directive('uiSelect', controllerAs: '$select', compile: function(tElement, tAttrs) { + // Allow setting ngClass on uiSelect + var match = /{(.*)}\s*{(.*)}/.exec(tAttrs.ngClass); + if(match) { + var combined = '{'+ match[1] +', '+ match[2] +'}'; + tAttrs.ngClass = combined; + tElement.attr('ng-class', combined); + } + //Multiple or Single depending if multiple attribute presence if (angular.isDefined(tAttrs.multiple)) tElement.append('').removeAttr('multiple');