【发布时间】:2018-07-13 19:49:58
【问题描述】:
我在 HTML 表中有一些数据。我必须使用分页显示表格条目,但我不知道如何使它工作。一些教程令人困惑,因为我是 angularjs 的初学者。谁能为此提供解决方案? 索引.html 这是我展示表格的模板
<div ng-controller="productscontroller">
<div id="rows">
Display:<input type="number" min=0 max=18 size=1 ng-model="rowstolimit" />
</div>
<div>
<table class="table">
<thead>
<tr><b>
<td><b>Product_id</b></td>
<td><b>Product_name</b></td>
<td><b>Highest_bid</b></td>
<td><b>Bid_expiry_date</b></td>
<td><b>Less_than_one_day</b></td>
<td><b>Demand_price</b></td>
</tr>
</thead>
<tbody>
<tr ng-repeat="product in details.productData.products | limitTo:rowstolimit">
<td>{{product.product_id}}</td>
<td>{{product.product_name}}</td>
<td>{{product.highest_bid}}</td>
<td>{{product.bid_expiry_date}}</td>
<td>{{product.less_than_one_day}}</td>
<td>{{product.demand_price}}</td>
</tr>
</tbody>
</table>
</div>
controller.js 在这里,我使用 featureseals 服务从 API 获取详细信息
var app = angular.module("myapp", ['ngRoute']);
app.controller("productscontroller", function($scope, $http, featuredeals, $location, $log) {
$scope.details = {
productData: []
}
featuredeals.processString()
.then(function(response) {
console.log(response);
$scope.details.productData = response.data.data;
},
function(reason) {
console.log(reason);
$log.info(reason.data);
});
});
【问题讨论】:
-
Smart Table 是一个很好的指令,可以解决本地和远程分页问题。 lorenzofox3.github.io/smart-table-website
标签: javascript angularjs html-table pagination