【发布时间】:2017-04-01 05:47:44
【问题描述】:
您好,我正在使用 angularjs 和带有数据表 js 的 ASP.NET MVC 创建一个应用程序。
在this 文章的帮助下,我已经使用带有角度 js 的数据表实现了表格显示数据。
但我想使用与列名相同的功能在 html 中静态绑定数据,例如:
在文章中作者使用:
<table id="entry-grid" datatable="" dt-options="dtOptions"
dt-columns="dtColumns" class="table table-hover">
</table>
但我想通过使用 ng-repeat 根据我的数据使用上述相同的功能来做到这一点:
<table id="tblusers" class="table table-bordered table-striped table-condensed datatable">
<thead>
<tr>
<th width="2%"></th>
<th>User Name</th>
<th>Email</th>
<th>LoginID</th>
<th>Location Name</th>
<th>Role</th>
<th width="7%" class="center-text">Active</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in Users">
<td><a href="#" ng-click="DeleteUser(user)"><span class="icon-trash"></span></a></td>
<td><a class="ahyperlink" href="#" ng-click="EditUser(user)">{{user.UserFirstName}} {{user.UserLastName}}</a></td>
<td>{{user.UserEmail}}</td>
<td>{{user.LoginID}}</td>
<td>{{user.LocationName}}</td>
<td>{{user.RoleName}}</td>
<td class="center-text" ng-if="user.IsActive == true"><span class="icon-check2"></span></td>
<td class="center-text" ng-if="user.IsActive == false"><span class="icon-close"></span></td>
</tr>
</tbody>
</table>
我还想在表中添加新列,使用按钮单击添加新记录时的相同功能。
有可能吗?
如果是的话,如果有人在 jsfiddle 或任何编辑器中向我展示,那将是很好的,并提前感谢。
请DOWNLOAD 在 Visual Studio 编辑器中创建的源代码用于演示
【问题讨论】:
-
您能否添加控制器和指令代码以了解您的代码
-
@SamuelJMathew 您可以在此article 中看到的所有代码除了我在问题中编写的代码以在 HTML 中静态绑定作为示例之外,我有相同的代码没有变化。
标签: angularjs datatables angular-datatables