我正在嘗試將頁面添加到我的列表中。我遵循了有關智能手機的AngularJS教程,我試圖僅顯示一定數量的對象。這是我的html文件: <div class='container-fluid'> <div class='row-fluid'> <div class='span2'> Search: <input ng-model='searchBar'> Sort by: <select ng-model='orderProp'> <option value='name'>Alphabetical</option> <option value='age'>Newest</option> </select> You selected the phones to be ordered by: {{orderProp}} </div> <div class='span10'> <select ng-model='limit'> <option value='5'>Show 5 per page</option> <option value='10'>Show 10 per page</option> <option value='15'>Show 15 per page</option> <option value='20'>Show 20 per page</option> </select> <ul class='phones'> <li class='thumbnail' ng-repeat='phone in phones | filter:searchBar | orderBy:orderProp | limitTo:limit'> <a href='#/phones/{{phone.id}}' class='thumb'><img ng-src='{{phone.imageUrl}}'></a> <a href='#/phones/{{phone.id}}'>{{phone.name}}</a> <p>{{phone.snippet}}</p> </li> </ul> </div> </div> </div>我添加了帶有某些值的select標簽,以限制將要顯示的項目數。我現(xiàn)在想要的是添加分頁以顯示下一個5、10等。我有一個與此相關的控制器:function PhoneListCtrl($scope, Phone){ $scope.phones = Phone.query(); $scope.orderProp = 'age'; $scope.limit = 5;}而且我還有一個模塊,以便從json文件中檢索數據。angular.module('phonecatServices', ['ngResource']). factory('Phone', function($resource){ return $resource('phones/:phoneId.json', {}, { query: {method: 'GET', params:{phoneId:'phones'}, isArray:true} }); });
使用ng-repeat在列表上分頁
慕森卡
2019-12-07 15:48:42