有人可以根据我的代码向我提供有关为什么我在标题中收到错误的见解吗?不太清楚为什么。
angular.module("demoApp", ['ngRoute'])
.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
$routeProvider.
when('someURL', {
templateUrl: 'someTemplate.html',
controller: 'CreateGrids'
});
$locationProvider.html5Mode(true);
}
])
.factory("servers", function () {
var servers = {};
...
return servers;
})
.factory("setup", function () {
var setup = {};
...
return setup;
})
.factory("gridservice", ['$http', function ($http) {
var gridservice = {};
...
return gridservice;
}])
.controller('MainCtrl', ['$route', '$routeParams', '$location',
function ($route, $routeParams, $location) {
this.$route = $route;
this.$location = $location;
this.$routeParams = $routeParams;
console.log(this.$routeParams);
}
])
.controller("CreateGrids", ['$routeParams', '$scope', '$http', 'setup', 'server', 'gridservice', function ($routeParams, $scope, $http, setup, servers, gridservice) {
this.name = 'CreateGrids';
this.params = $routeParams;
console.log($routeParams);
...
}])
.controller("ServerRepeat", ['$scope', 'servers', 'setup', function ($scope, servers, setup) {
...
}
}]);
我已经多次检查代码以尝试找出导致错误的原因,但无济于事。是因为我在控制器和工厂之间调用东西吗?
编辑:这是错误
Error: [$injector:unpr] http://errors.angularjs.org/1.3.0-beta.17/$injector/unpr?p0=serverProvider%20%3C-%20server
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:6:457
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:37:55
at Object.d [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:35:74)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:37:129
at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:35:74)
at e (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:35:335)
at Object.instantiate (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:35:494)
at $get (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:69:169)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js:54:454