-
Notifications
You must be signed in to change notification settings - Fork 1.8k
ng-class on ui-select #277
Comments
|
Also experiencing this issue using Example select:
The console error on loading the page:
|
Validation is limited - does not highlight the select box when validation fails, since mg-class cannot be used currently with ui-select - see angular-ui/ui-select#277
Same error here. |
Same here, did anybody manage to resolve it? |
Just add a semicolon after your custom ng-class. This will take care of the error. |
I have the same error, adding a semicolon doesn't solve the problem (version 0.8.4) |
The problem is because |
I am also experiencing the same issue, has there been any resolution yet? |
In the meatime I have added the following to the compile fn in the uiSelect directive, +/- line 730. Not perfect but its working for my requirements.
|
you can hack it by add it to class="{{condition ? 'class_a' : ' ' }}" |
I also have this issue, is there any resolution for this yet? For the time being, I have used a workaround, but it is not desired :/ |
anyone have any work around to deal with ng-class , i need UI-Select to take different classes( like Width) |
+1 |
1 similar comment
+1 |
+1, the proper fix will be very appreciated. |
+1 |
3 similar comments
+1 |
+1 |
+1 |
Being spammed by mail ^^ (Holy github notifications), I decided to take @grantfeldman 's example: This snippet below is supposed to be placed at select.js#L870 var match = /{(.*)}\s*{(.*)}/.exec(tAttrs.ngClass);
if(match) {
var combined = '{'+ match[1] +', '+ match[2] +'}';
tAttrs.ngClass = combined;
tElement.attr('ng-class', combined);
} I will make a PR. |
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
fix(ui-select): 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 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
You need to escape the open braces:
|
@antoniodesousa Could you explain why? I have run both through a Regex parser and its showing no difference between the two patterns. |
The only reason why you would escape open braces is when you match a number, right ? |
The open curly brace should be escaped because it is a special character used for quantifiers eg {2,3} |
As defined by the ECMA specification (5.1 as well as 2015), a quantifier can be described as:
In strict POSIX Basic Regular Expressions (BRE), a regex matching a quantifier would be: Since |
Can we get some clarification on this? I'm looking to apply a class to a specific item that is selected if an expression is true. |
Hi @engemasa, are you looking for clarification on the specification? or the issue itself - as i believe the issue was merged a while back. |
Sorry for not being more specific in my original post @grantfeldman. I'm looking for code or an example on how to utilize this. I'm trying to add a class to a selected item conditionally. (i.e. ng-class="{'myClass' : $item.value == ctrl.someValue}". I hope this clears it up. |
@engemasa your code looks fine to me. Are you using the latest version? Can you test the ng-class expression on another element (not ui-select) to test? |
That's where I'm getting confused. Which element should I put the ng-class on? I'm going to guess and say it's the ui-select-match element? |
@engemasa I have only used ng-class on the ui-select element so not sure if it works on ui-select-match. |
Ok, I have a sneaking suspicion that a fellow team member is using an old version. I will double-check this in a little while. @grantfeldman, Thank you for you quick responses! |
No problem. good luck. |
I have made a plnkr with an example. My confusion is where to use the ng-class. http://plnkr.co/edit/43PMErMiIBiCQMc80rJE?p=preview (Look at the home.html and homeCtrl.js files) In this example, I would expect to have the item with an ID of 'AB134' to have a "red" class applied to it and styled as such (red background, white text). I have tried it both ways with the ng-class only on the ui-select element and only on the ui-select-match element. |
Try this?
|
This is a step in a right direction. I think ideally the class should be applied to the span.ui-select-match-item element which is why I kept trying to put it on the ui-select-match element Here are screenshots of what I'm trying to accomplish vs how it currently works. http://imgur.com/a/iP9mu |
@engemasa Yeah i saw that as well. I think the best way forward would be to have a look at the ui-select source, make some changes and see if you can get it working locally. If so then make a pull request? |
I will give it a shot. I already forked the repo. Thank you! On Tue, Aug 30, 2016, 9:42 PM Grant [email protected] wrote:
|
hi @engemasa have you got a solution for the problem? I've been stuck at it as well. Thanks |
I have the same problem, I did the following workaround, I put the ui-select element inside another div element and apply ng-class to div element then on css add style to the ui select classes (ui-select-container) |
+1 |
Hi any updates for this issue? Thanks! |
@tproenza No updates , are you looking for something specific? |
Cannot put ng-class on element ui-select
The text was updated successfully, but these errors were encountered: