ASP.NET MVC - loop model data in javascript

Key: razor syntax using @: before the js variable in c# code block

Example:

 var chartData = [];

        @for(int i=0; i < Model.ModuleDetails.Count; i++)
        {
            @: chartData.push(@Html.Raw(Json.Encode(Model.ModuleDetails[i].ChartData.ToArray())));
        }

reference:

http://stackoverflow.com/questions/2002831/asp-net-mvc-how-can-you-loop-through-model-data-in-javascript


你可能感兴趣的:(ASP.NET MVC - loop model data in javascript)