Andrew Mairose Andrew Mairose - 2 months ago 22
AngularJS Question

Thymeleaf parsing error when using "&&" in AngularJS expression

I have an AngularJS

ng-show
attribute in my Thymeleaf template that looks something like this:

<span ng-show="aIsValid && bIsValid"></span>


When Thymeleaf tries to process this template, I get the following exception:


org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.


Does Thymeleaf just not play nicely with
&&
logic in Angular attributes? Or is there a workaround for this other than slapping a method on my
$scope
that will simply
return $scope.aIsValid && $scope.bIsValid
?

Answer

Replace && with &amp;&amp; because & must be escaped in XML.