我正在使用angularjs 1.5.7并继续低于错误:
angular.min.js:117错误:[$ injector:unpr] http://errors.angularjs.org/1.5.7/ $ injector / unpr?p0 = ngTableProvider%20%3C-%20ngTable%20%3C-%20CustomerBuyController at Error(native)
以下是我所做的
**index.html**
<html ng-app="myapp">
<head>
<link href="css/vendor/ng-table.min.css" rel="stylesheet">
</head>
<body>
...
<script src="js/vendor/jquery-2.2.4.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-2.2.4.min.js"><\/script>')</script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/vendor/angular.min.js"></script>
<script src="js/vendor/angular-route.min.js"></script>
<script src="js/vendor/ng-table.min.js"></script>
<script src="js/app/controller-customer-buy.js"></script>
</body>
</html>
**app.js**
var app = angular.module('myapp',["ngRoute", "ngTable"]);
**route.js**
angular.module('myapp').config(function($routeProvider, $locationProvider, $httpProvider) {
var checkLoggedin = function($q, $timeout, $http, $location, $rootScope){
// Initialize a new promise
var deferred = $q.defer();
if(!sessionStorage.getItem('userToken')) {
$location.url('/login');
deferred.resolve();
} else {
$http({
method: 'POST',
url: 'http://127.0.0.1:8008/is-valid-user-token',
data: {
token: sessionStorage.getItem('userToken')
}
}).then(function successCallback(response) {
$location.url('/buy');
deferred.resolve();
}, function errorCallback(response) {
$location.url('/login');
deferred.reject();
});
}
return deferred.promise;
};
$httpProvider.interceptors.push(function($q, $location) {
return {
response: function(response) {
// do something on success
return response;
},
responseError: function(response) {
if (response.status === 401)
$location.url('/login');
return $q.reject(response);
}
};
});
$routeProvider
.when('/', {
templateUrl : 'pages/home.html'
})
.when('/login', {
templateUrl : 'pages/login.html',
controller : 'LoginController',
resolve: {
loggedin: checkLoggedin
}
})
.when('/buy', {
templateUrl : 'pages/customer-buy.html',
controller : 'CustomerBuyController',
resolve: {
loggedin: checkLoggedin
}
})
.otherwise({redirectTo: '/'});
}).run(function($rootScope, $http, $location){
// ......
});
**controller-customer-buy.js**
(function () {
'use strict';
angular.module('myapp').controller('CustomerBuyController',
['$rootScope', '$scope', '$parse', '$http', 'ngTable' ,function($rootScope, $scope, $parse, $http, ngTable) {
});
})();