AngularJS 表格
- 上一页 AngularJS Http
- 下一页 AngularJS 选择
ng-repeat 指令非常适合显示表格。
在表格中显示数据
使用 AngularJS 显示表格非常简单:
AngularJS 实例
<div ng-app="myApp" ng-controller="customersCtrl">
{{ x.Country }} |
使用 CSS 样式显示
为了让它看起来更漂亮,可以向页面添加一些 CSS:
CSS 样式
<style> table, th , td { border: 1px solid grey; border-collapse: collapse; padding: 5px; } table tr:nth-child(odd) { background-color: #f1f1f1; } table tr:nth-child(even) { background-color: #ffffff; } </style>
使用 orderBy 过滤器显示
要对表进行排序,请添加 orderBy
过滤器:
AngularJS Example
{{ x.Country }} |
使用 uppercase 过滤器显示
要以大写形式显示,请添加 uppercase
过滤器:
AngularJS Example
显示表索引 ($index)
要显示表索引,请添加带有 $index
的 <td>:
AngularJS Example
{{ x.Country }} |
使用 $even 和 $odd
AngularJS Example
{{ x.Name }} | {{ x.Name }} | {{ x.Country }} | {{ x.Country }} |
- 上一页 AngularJS Http
- 下一页 AngularJS 选择