This is probably a beginner question but I can only find the other way round (from view back to the controller).
What I have is a ViewModel which contains the following property:
public class MyViewModel {
List<decimal> PossibleValues {get; set; }
}
I would now like to consume this list of values in a jquery variable inside my view:
@model MyViewModel
<script>
$(function() {
var vals = @Model.PossibleValues;
// should be var vals = [1.0, 2.0, 3.0];
});
</script>
What is the "correct" way to pass this list of decimals into the jquery section. I can think of JSONfying the data or simply passing a string of preformatted values but I was wondering if there is a nicer way to do this?