I have the following Razor code :
@{
var villages = (List<string>) @ViewData["allVillages"];
}
@if (villages != null)
{
<script type="text/javascript">
var villages = @villages;
</script>
}
But when I want to use the variable "villages" in JS I get :
ReferenceError: villages is not defined
How can I do it ?