How can I get the value of the first item from the model's List? My ViewModel:
namespace TestWeb
{
public class NavViewModel
{
public NavViewModel()
{
NavStepList = new List<NavStep>();
}
public List<NavStep> NavStepList { get; set; }
}
}
In my View:
@using TestWeb
@model NavViewModel
<script>
$(document).ready(function () {
var Testvalue = @Model.NavStepList.First();
});
</script>
I want the first value of NavStepList
. However an error occurs when I call this function:
TestWeb is undefined
I already test with testing value assign to NavStepList
but the error still occurs.
My NavStep Class Property:
public class NavStep{
public int NavStepId { get; set; }
public int SortId { get; set; }
public string StepName { get; set; }
public string IdentifierKey { get; set; }
public bool IsAvailible { get; set; }
}