-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Class setting broken when combining ng-class and multiple interpolations in class attribute #10811
Comments
Hi, to clarify, the problem is that when you mouseover an item, a specific class does not get applied? Or is the class applied, but the styling is not? It would really help if you could reduce the example even more, i.e. remove all parts of the code and styling that have nothing to do with the problem. |
Hi, Thanks!! |
Did you save the plunker? It looks like it's the same one. |
Okay, I see the mouseover is gone. However, there's still too much going on. Sometimes the button "containers" change color erratically, turning to white and black, then back to purple. Happens in both 1.2.x and 1.3.x. Is there actually a way to reproduce this in a plunkr? What exactly should I do and see (which colors when if you want)? |
I'm using chrome browser, and it's work fine in 1.2.x version!. |
@chezih: Your plunkr is sooo far away from an SSCCE. There is so much unrelated stuff in there, that makes it difficult and time-consuming to isolate the problem. That said, the problem seems to be caused by the use of interpolated keys in the I am not sure if interpolated keys were intentionally supported in older versions (I had no idea they even worked), or supported "by chance", in which case we wouldn't fix this. |
Although I don't believe it is the same issue, point (D) on #9109 (comment) might be relevant. |
@gkalpak That looks interesting! I have reduced the problem to this form: Once you have ng-Class and two interpolations in the Looks like a nice debugging experience for a cold and dark winter night. |
I also tracked the breakage down to 1.3.0-beta.19; unfortunately there are a ton of changes that could be the cause. |
@gkalpak - Thank for your comments!! - I'll try to do it better for next time... |
@chezih Your problem is fixed by removing one of the interpolated classes in the |
@Narretz - thanks!! |
@Narretz: I don't think your plunkr reproduces the problem. It reproduces the problem in #9109, but I believe it is a different issue. E.g. removing the one interpolation from @chezih: Tried with the template function and it doesn't work either. It seems to be One more reason for deprecating |
@gkalpak I tested it with the original plnkr (which has interpolated ngClass key), and it works once I remove one interpolated class from the class attribute. Strange! |
@Narretz: Hm...indeed it does. I am pretty sure I tried that and it didn't work (but obviously I did something else). Then it might be more related to #9109 than I thought. Or there might be more than one issues going on here. I don't know.
|
+1. I've found out that directive transclude is used along with directive replace, you can not use interpolations in the class -- if I try to interpolate anything, the class gets put twice inside, and the interpolations are always empty. |
+1 this is a problem when application starts with x == y, no "selected" class is applied until either ngAnimate is removed or {{x}} expression is removed from class attribute. |
+1 Can we expect to solve the problem in the near future? |
+1 The same problem on Angular 1.5.x |
This is a (documented) known issue afaict (see here and there) and there are no plans to fix this. Based on that, I am going to close this as won't fix. If you are facing a different problem (that doesn't fall into the "known issue" category), please open a new issue. |
I'm in the middle of the transition from version 1.2.* to 1.3.* , and I came across a very strange and critical bug.
In my application I have a very simple
directive
contain atemplate
withng-class
(with condition to scope property) for some reason it's not working with 1.3.* version, and it's work fine with 1.2.* version.Have a look on this Plunker to illustrates the problem.
This
Plunker
code is with angular 1.2.* version, and as you can see it's work fine.Try to change the angular version (index.html)
Refresh the page, and then you can see the bug:
Angular doesn't refresh the ng-class according to the 'active' property changing.
I tried to understand what can causes to this bug, and after a lot of tries I found that
'ngAnimate'
module causes to this problem. try to delete the'ngAnimate'
dependency (script.js):And then you can see that everything is fine, so
'ngAnimate'
version 1.3.* causes to this problem.So it's AngularJS bug, am I right?
If not, what I'm doing wrong?
The text was updated successfully, but these errors were encountered: