Skip to content

Commit 6a99b08

Browse files
author
Jean-Baptiste Lenglet
committed
fix: Allow setting a ngClass on <ui-select> element
Since a ngClass is already present in the uiSelect theme templates, we could not add any ngClass on <ui-select> without getting an JS error Currently, adding a ngClass on <ui-select> 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 angular-ui#277
1 parent b1c4fdc commit 6a99b08

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/uiSelectDirective.js

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ uis.directive('uiSelect',
1717
controllerAs: '$select',
1818
compile: function(tElement, tAttrs) {
1919

20+
// Allow setting ngClass on uiSelect
21+
var match = /{(.*)}\s*{(.*)}/.exec(tAttrs.ngClass);
22+
if(match) {
23+
var combined = '{'+ match[1] +', '+ match[2] +'}';
24+
tAttrs.ngClass = combined;
25+
tElement.attr('ng-class', combined);
26+
}
27+
2028
//Multiple or Single depending if multiple attribute presence
2129
if (angular.isDefined(tAttrs.multiple))
2230
tElement.append('<ui-select-multiple/>').removeAttr('multiple');

0 commit comments

Comments
 (0)