I'm trying to use a Spring variable in javascript:
Map<String, List<String>> states;
and I found some information here
so I tried:
<script th:inline="javascript">
/*<![CDATA[*/
var xxx = ${states};
console.log(xxx);
/*]]>*/
</script>
In my browser's source tab I have something like:
var xxx = {STATE1=[a, b, c, d]};
console.log(xxx);
and the error is: Uncaught SyntaxError: Invalid shorthand property initializer
.
I also tried with: var xxx = /*[[${states}]]*/ 'foo';
and if i print console.log(xxx)
, I got 'foo'
.