Reputation: 11201
I have some data in My controller which i want to use in Javascript in my gsp file
class MainController {
def test = {
def value = 111.10
}
}
TEST.GSP
<html>
<head><title>Simple GSP page</title></head>
<body>
<script language="JavaScript">
alert("${value}")
</script>
</body>
</html>
Dialog box appears but without any value .. Any Solution ..?
Thanks
Upvotes: 0
Views: 1718
Reputation: 8109
You need to explain grails, that he local variable value
should be accessible in the view, by returning a map of all variables, that should be accessible in the view:
class MainController {
def test = {
def value = 111.10
[value: value]
}
}
Upvotes: 1