[英]AngularJS - ui-bootstrap pagination error
Im getting an error with ui-bootstrap pagination Unknown provider: startFromFilterProvider 我在ui-bootstrap分页时遇到错误未知提供程序:startFromFilterProvider
Here is my controller code: 这是我的控制器代码:
function observedCars($scope, $http, API, CarDetailService, $state) {
$http.get( API + '/car/?observed=true&offset=0&page_size=20' ).
success(function(data) {
$scope.observed = data;
});
$scope.pageSize = 5;
$scope.currentPage = 1;
$scope.selectCar = function(carId) {
CarDetailService.setCar(carId);
$state.go('taskDetails');
};
}
Here is the HTML: 这是HTML:
<div ng-controller="observedCars">
<div ng-repeat="obv in observed['Observed CARs'] | startFrom:(currentPage - 1) * pageSize | limitTo: pageSize" class="myCar">
<div class="carId">{{ obv['Display Name'] }}</div>
<div class="title">{{ obv['Project Title'] }}</div>
<div class="status"> {{obv.Status}} </div>
<h4><u>Current Approver</u></h4>
<div class="currApp dont-break-out">{{obv['Current Approver']}}</div>
<h4><u>Amount</u></h4>
<div class="modified">${{obv.Amount | number:2}}</div>
<div class="carBtnWrap">
<div class="viewCar"><a ng-click="selectCar(obv['CAR ID'])">View Details</a></div>
</div>
</div>
<ul uib-pagination total-items="observed['Observed CARs'].length" ng-model="currentPage" items-per-page="pageSize"></ul>
</div>
Also I should mention that it does show the right amount of button numbers in "uib-pagination" button section. 我还要提到的是,它确实在“ uib-pagination”按钮部分显示了正确数量的按钮编号。 So the proper amount of pages loads just not data cause of the error. 因此,适当的页面加载量只是错误的数据原因。
How can I fix this 我怎样才能解决这个问题
Thanks 谢谢
It seems that you didn't declare or define the startFrom filter. 似乎您没有声明或定义startFrom过滤器。 There is an exemple found here : AngularJS with AngularUI Bootsrap pagination directive doesn't hide results 这里有一个示例 : 带有AngularUI Bootsrap分页指令的AngularJS不会隐藏结果
app.filter('startFrom', function () {
return function (input, start) {
if (input === undefined || input === null || input.length === 0
|| start === undefined || start === null || start.length === 0 || start === NaN) return [];
start = +start; //parse to int
try {
var result = input.slice(start);
return result;
} catch (e) {
// alert(input);
}
}
});
You are using a startFrom
filter in the following expression: <div ng-repeat="obv in observed['Observed CARs'] | startFrom:(currentPage - 1) * pageSize | limitTo: pageSize" class="myCar">
您在以下表达式中使用startFrom
过滤器: <div ng-repeat="obv in observed['Observed CARs'] | startFrom:(currentPage - 1) * pageSize | limitTo: pageSize" class="myCar">
You can probably copy the implementation for startFrom
from your example, or you forgot to embed it. 您可能可以从示例中复制startFrom
的实现,或者忘记嵌入它。 A common implementation is as follows: 常见的实现如下:
module.filter('startFrom', function () {
return function (input, skipCount) {
if (!input) return input;
return input.slice(skipCount);
};
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.