【发布时间】:2014-07-23 09:46:47
【问题描述】:
我对 Angularjs 很陌生,我想实现一个类似于这个 jsfiddel http://jsfiddle.net/NfPcH/93/ 的可编辑表(从官方 angular 文档中检索)但是我如何用数据列表填充表而不是硬编码数据从 MVC 或 ViewBag 中的数据库中检索?
例如,而不是下面的这个 MVC 表,我想实现相同的目标,而是使用 Angular 来使表可编辑。
@if (ViewBag.Session != null)
{
<table class="table table-hover">
<tr>
<th>
ID
</th>
<th>
Name
</th>
<th>
Surname
</th>
<th>
House
</th>
<th>
Address
</th>
<th>
Locality
</th>
<th>
Contact
</th>
<th>
Contact 2
</th>
<th>
Contact 3
</th>
<th>
Reply
</th>
<th>
Edit
</th>
</tr>
@foreach (var item in ViewBag.Session)
{
<tr>
<td>
@item.ID
</td>
<td>
@item.Name
</td>
<td>
@item.Surname
</td>
<td>
@item.House
</td>
<td>
@item.Address
</td>
<td>
@item.Locality
</td>
<td>
@item.Contact1
</td>
<td>
@item.Contact2
</td>
<td>
@item.Contact3
</td>
<td>
@item.Reply
</td>
</tr>
}
</table>
另外,当一行发生变化并保存时,如何将数据发送回后台保存到数据库中?
【问题讨论】:
-
AngularJS 的方法与 ASP.NET MVC 完全不同。尝试先了解 Angular github.com/jmcunningham/AngularJS-Learning
标签: mysql asp.net-mvc angularjs model-view-controller