gpt4 book ai didi

javascript - AngularJS - ui-bootstrap 分页错误

转载 作者:行者123 更新时间:2023-12-02 14:16:32 25 4
gpt4 key购买 nike

我收到 ui-bootstrap 分页错误未知提供程序:startFromFilterProvider

这是我的 Controller 代码:

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');
};
}

这是 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>

我还应该提到,它确实在“uib-pagination”按钮部分显示了正确数量的按钮编号。因此,适当数量的页面加载并不是导致错误的数据原因。

如何解决这个问题

谢谢

最佳答案

您似乎没有声明或定义 startFrom 过滤器。这里有一个例子:AngularJS with AngularUI Bootsrap pagination directive doesn't hide results

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);
}

}
});

关于javascript - AngularJS - ui-bootstrap 分页错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38984321/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com