I want to convert the Model property of a List type to a Javascript variable used in the same view. This is my model:
public string Title { get; set; }
public string Description { get; set; }
public List<String> ImgLinks { get; set; }
I need a Javascript or json array of the ImgLinks properties of my model. I tried -
var imageLinks = @(Html.Raw(Json.Encode(Model.ImgLinks)));
But I get a syntax error warning. Can someone help me with converting to javascript array and json?
source
share