I try to pass an array from a controller to a javascript code into a gsp page. I tried with
Controller :
def stat(){
def listSubject = [["Physique", 10, 85, 1], ["Arabe", 20, 14, 3]]
[listSubject]
}
stat.gsp :
var data=${listSubject} ;
But it looks like considering the data as if it was a string and not an array. I tried also to add
var data=${listSubject.encodeAsJavaScript()} ;
But No result is matched. Please i need your helps :( Thanks
[listSubject]has no meaning outside of the context of the controller action. It will have a meaning if the model (of MVC) is tailored appropriately, which means[listSubject: listSubject]will create a key<>value in the model which can then be accessed in the gsp as${listSubject}.