Assuming your model is actually @model graph_user
and not @model IEnumerable<graph_user>
(your current definition would not compile)
You can assign you models collection to a javascript variable using
var yearList = @Html.Raw(Json.Encode(Model.year))
Then iterate over it using
$.each(yearList, function(index, item) {
var year = item;
// do something with it
});
Side note: Recommend you follow normal naming conventions and name your property Years
- plural - (not year
) and your class GraphUser
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…