Encountering the same issue, it seems to be related to a timing problem, but there is a workaround available.
Essentially, there seems to be a conflict between a class defined in the "class" attribute with interpolation, and other directives on the same element that attempt to introduce another class. By removing the class="{{::item.customClass}}"
, the ng-class and ng-show directives function properly.
While I was unable to replicate the issue on a plunker due to the complexity of the components involved, we utilize services such as $templateCache, modules like ngAnimate, and a directive incorporating ng-repeat with dynamic class and ng-show (among others, which didn't seem to impact the problem). Removing any of these elements resolved the issue. One option I haven't explored yet is detaching the code from the ui-view
hierarchy, suspecting that ui-router could be contributing to the problem.
Upon debugging, it was observed that following the execution of the ng-class/ng-show watch, the appropriate class was added initially as:
class="{{::item.customClass}} ng-hide"
, however by the end of the digest cycle, it appeared as:
class="myCustomClass"
. This is likely the situation you are also encountering.
To manage this situation, I relocated item.customClass
to the ng-class section as follows:
ng-class=[{ ... other classes}, item.customClass]
This serves as a temporary fix rather than a definitive solution due to:
- The likelihood of an underlying issue within Angular's codebase.
- A lack of knowledge on implementing bind once here, despite its significance.