i have a returnig list result from controller to View
@model List<CartItemDetailDto>
is it possible to have this result list set to a jquery variable
<script>
var modelList =@(Model);
</script>
CodePudding user response:
var modelList =JSON.parse('@Html.Raw(Model)')
CodePudding user response:
Yes you can use that. Just convert in to Json String like below:
json = @Html.Raw(Json.Encode(@Model));
var data = JSON.parse(JSON.stringify(json));
now you can use your model data in Jquery.