需要的文件:
- angular.js
- ng-table.js
- ng-table.css
- bootrasp.css
注入依赖:
var app = angular.module('app', [
'ngTable',
'ui.bootstrap',
]);
为ng-table设置数据
app.controller('controller', function($scope,NgTableParams) {
$http.get("/query")
.success(function(data) {
$scope.userTable = new NgTableParams({
page : ,
count :
}, {
total : data.length,
getData : data
}
});
})
});
}
为 table 添加 ng-table 属性
<table ng-table="userTable" class="table table-hover">
<tbody>
<tr>
<th>编号</th>
<th>用户名</th>
</tr>
<tr ng-repeat="user in $data">
<td>{{user.id}}</td>
<td>{{user.name}}</td>
</tr>
</tbody>
</table>