Change my-class to myclass (i.e. the error is causing the problem).
<div ng-controller="Ctrl" ng-app> <div ng-class="myclass">This div will change class when one hovers over bottom DIV </div> <br/> <div class="hover-div" ng-mouseenter="myclass = 'highlight'" ng-mouseleave="myclass = 'lowlight'">HOVER OVER ME TO CHANGE THE UPPER DIV CLASS</div> </div>
Updated: the reason my-class not allowed in the expression because AngularJS treats the dash as a minus character and tries to parse it that way. Apparently, he cannot parse the statement my - class = 'highlight' . Unfortunately, after reading the AngularJS parser code, I cannot find a way to βhelpβ it to distinguish between dashes and minus.
Buu nguyen
source share