2
我有這個模式,返回其在表格編輯:如何獲得型號列表<string> jQuery中
public class NewsVM
{
public List<string> Tags{get;set;}
}
,並在行動:
public ActionResult Edit()
{
//create instance and fill it
return View(mymodel);
}
和jQuery中的視圖我想要獲取Tags
和將它們全部添加到我的div中。我怎樣才能做到這一點 ?
我用這個,但不行 :
@if (Model != null)
{
<script type="text/javascript">
for (var i = 0; i < @Model.Tags.Count; i++) {
alert('@Model.Tags["i"]');
}
</script>
}
你爲什麼不只是用剃刀將其添加? – kmcoulson
你能回答嗎?我想獲取所有列表並將其全部添加到div。 –