I have an IEnumerable<> of Car(here it wont let me use angle brackets properly) model used in my view : and in my JavaScript I have to create an array of object corresponding to object in my model. I have trouble iterating through my model in JavaScript If I use razor, the javascript code is not working:
<script type="text/javascript"> var carsArray = new Array(); @foreach (var item in Model) { //add the and item to carsArray object } //OR for(i=0;i<@Model.Count();i++) { alert(@Model.ElementAt(i).Title); //Error: The name 'i' does not exist in the current context
//add to array } </script> Thank you!