我已从Angular 1.0.8升级到Angular 1.2.22,但我收到以下错误:
Error: [$injector:modulerr] http://errors.angularjs.org/1.2.22/$injector/modulerr?p0=gameApp&p1=%5B%24injector%3Aunpr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.2.22%2F%24injector%2Funpr%3Fp0%3D%2524routeProvider%0Aw%2F%3C%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A6%3A443%0Agc%2Fl.%24injector%3C%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A36%3A139%0Ac%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A34%3A204%0Ad%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A34%3A418%0Ae%2F%3C%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A33%3A327%0Ar%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A7%3A288%0Ae%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A33%3A148%0Agc%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A36%3A250%0Afc%2Fc%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A18%3A58%0Afc%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A18%3A270%0AXc%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A17%3A359%0A%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A214%3A78%0Aa%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A144%3A390%0Aoe%2Fc%2F%3C%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A31%3A159%0Ar%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A7%3A288%0Aoe%2Fc%40https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.22%2Fangular.min.js%3A31%3A143%0A
...p"+(c-1)+"="+encodeURIComponent("function"==typeof arguments[c]?arguments[c].toS...
我不知道这是什么错误?
这是我的AngularJS代码:
var gameApp = angular.module("gameApp", []);
gameApp.service('link', function() {
this.user = false;
});
function makeTableFrom(str) {
var k = 1;
result = "";
for(var i = 1; i <= 8; i++) {
result += '<tr>';
for(var j = 1; j <= 20; j++) {
if(str[k] === '#') {
result += '<td id=' + k + '">#</td>';
}
else if(str[k] === '&') {
result += '<td class="click" val="water" id="' + k + '">&</td>';
}
else {
result += '<td class="click" id="' + k + '"><a href="#"></a></td>';
}
k++;
}
result += '</tr>';
}
return result;
}
gameApp.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl : 'partials/firstpage.html',
controller : 'firstPageCtrl'
})
.when('/game', {
templateUrl : 'partials/game.html',
controller : 'gameCtrl'
});
});
gameApp.controller("firstPageCtrl", function($scope,$http,link,$location) {
$scope.doLogin = function() {
$http.post("lib/action.php", {username: $scope.username, password: $scope.password}).success(function(data) {
if(data) {
link.user = data;
console.log(link.user);
$location.path("/game");
}
}).error(function(data) {
console.log(data);
});
};
});
gameApp.controller("gameCtrl", function($scope,$http,link,$location) {
//$scope.trr = [1,2,3,4,5,6,7,8];
//$scope.tdd = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
$scope.getMonsters = "1";
var map;
$http.post("lib/action.php", {monsters: $scope.getMonsters}).success(function(data) {
map = data;
console.log(map);
$scope.result = makeTableFrom(data);
console.log(result);
});
if(link.user) {
/*$scope.message = "fisk";
console.log(link.user);*/
} else {
/*$scope.message = "Ledsen fisk";
console.log("Är inte satt");*/
}
});
有谁可以帮我解决此错误?当我从1.0.8升级到1.2.22
时会发生这种情况答案 0 :(得分:1)
你可能错过了一些进口产品。 Angualr已经模块化,因此您需要指定注入应用程序的模块。
这是我的应用程序的注射设置(我猜你会错过'ngRoute'):
var app = angular.module('app', [
// Angular modules
'ngAnimate', // animations
'ngRoute', // routing
'ngSanitize', // sanitizes html bindings (ex: sidebar.js)
// Custom modules
'common', // common functions, logger, spinner
'common.bootstrap', // bootstrap dialog wrapper functions
// 3rd Party Modules
'ui.bootstrap', // ui-bootstrap (ex: carousel, pagination, dialog)
'breeze.angular'
]);
答案 1 :(得分:0)
您会注意到错误中包含URL,您可以点击该错误以获取更多信息。
在版本1.2.0中,角度分割出其ngRoute
等模块,以便它们可以被第三方版本(例如uiRouter)替换。
因此,您需要将angular-route.js
的v.1.2.22添加到您的网页以继续使用$routeProvider
。
您可以使用bower install angular-route
(如果您使用凉亭),或从here
您还需要添加ngRoute
作为gameApp
的依赖项:
var gameApp = angular.module("gameApp", ['ngRoute']);
注意:如果您使用过以前属于核心的其他模块,则可能会发生这种情况,修复方法是相同的。