我正在尝试在我的应用中使用此pagination。出于某种原因,我将在那里使用分页的部分视图无法识别
<li dir-paginate></li> and <dir-pagination-controls></dir-pagination-controls>
我的猜测是我的角度应用程序中的依赖注入是错误的。这是我的app模块:(app.js)
var AngularSpringApp = angular.module('AngularSpringApp', ['angularUtils.directives.dirPagination']);
这是我的控制器(KitController.js),它与视图相关联:
var KitController = function ($scope, $http) {
$scope.kit = {};
$scope.fetchKitList = function () {
$http.get('kits/show').success(function (kitList) {
$scope.kits = kitList;
});
};
$scope.addKit = function (kit) {
$http.post('kits/add', kit).success(function () {
$scope.fetchKitList();
$scope.kit.owner = '';
$scope.kit.category = '';
});
};
$scope.resetKitForm = function () {
$scope.kit = {};
};
$scope.currentPage = 1;
$scope.pageSize = 10;
};
KitController.$inject = ['$scope', '$http'];
AngularSpringApp.controller('KitController', KitController);
该应用程序正在运行,没有最后两行。控制器很好,因为它适用于其他功能。
以下是来自控制台的错误:
Attr.specified is deprecated. Its value is always true. angular.js:3887
TypeError: undefined is not a function
at dirPaginationLinkFn (http://localhost:8084/app/resources/js/dirPagination.js:107:31)
at nodeLinkFn (http://localhost:8084/app/resources/js/lib/angular/angular.js:4240:13)
at compositeLinkFn (http://localhost:8084/app/resources/js/lib/angular/angular.js:3851:14)
at compositeLinkFn (http://localhost:8084/app/resources/js/lib/angular/angular.js:3854:12)
at compositeLinkFn (http://localhost:8084/app/resources/js/lib/angular/angular.js:3854:12)
at publicLinkFn (http://localhost:8084/app/resources/js/lib/angular/angular.js:3763:30)
at update (http://localhost:8084/app/resources/js/lib/angular/angular.js:13890:11)
at Object.Scope.$broadcast (http://localhost:8084/app/resources/js/lib/angular/angular.js:8090:28)
at http://localhost:8084/app/resources/js/lib/angular/angular.js:7250:26
at wrappedCallback (http://localhost:8084/app/resources/js/lib/angular/angular.js:6650:59) <!-- ngRepeat: item in data | itemsPerPage: 2 --> angular.js:5582
GET http://localhost:8084/app/function%20(elem,%20attrs)%20%7B%20%20%20%20%20%2…%7C%20paginationTemplate.getPath();%20%20%20%20%20%20%20%20%20%20%20%20%7D 404 (Not Found) angular.js:9052
Uncaught TypeError: undefined is not a function
知道这是什么问题吗?
答案 0 :(得分:1)
好吧,问题似乎是我在项目中使用的angular.js文件非常旧(v1.0.3)。我试图用最新版本的角度替换它,但我收到有关ngRoute的错误。似乎旧版本的角度包括ngRoute,但现在它是一个单独的module必须添加。更新angular.js解决了这个问题!