[英]Angular: 'modulerr', "Failed to instantiate module
I'm trying to learn Angular and hitting a brick wall trying to add routes to my application. 我试图学习Angular并碰到一堵砖墙,试图向我的应用程序添加路线。
I keep getting presented this error 我不断收到这个错误
'modulerr', "Failed to instantiate module 'modulerr',“无法实例化模块
From other stackoverflow questions i gather its not from loading ngRoute correctly but angular-route.js is loaded in the head, and ngRoute is declared in my module construct so i'm a bit confused 从其他stackoverflow问题中,我不是从正确加载ngRoute收集到的,而是在头部加载angular-route.js,并且在模块构造中声明了ngRoute,所以我有点困惑
My index file is as followed 我的索引文件如下
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.js"></script>
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/1.1.2/angularfire.min.js"></script>
<script src="js/app.js"></script>
<script src="js/animations.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/services.js"></script>
</head>
<body ng-app="pgpChatApp">
<div class="view-container">
<div ng-view="" class="view-frame"></div>
</div>
</body>
</html>
My app file 我的应用程式档案
'use strict';
var pgpChatApp = angular.module('pgpChatApp', [
'ngRoute',
'firebase',
'pgpChatAnimations',
'pgpChatControllers',
'pgpChatFilters',
'pgpChatServices'
]);
pgpChatApp.config(["$routeProvider", function ($routeProvider) {
$routeProvider.when("/home", {
// the rest is the same for ui-router and ngRoute...
controller: "userAuth",
templateUrl: "partials/home.html"
}).when("/account", {
// the rest is the same for ui-router and ngRoute...
controller: "AccountCtrl",
templateUrl: "partials/msg_room.html",
resolve: {
// controller will not be loaded until $requireAuth resolves
// Auth refers to our $firebaseAuth wrapper in the example above
"currentAuth": ["Auth", function (Auth) {
// $requireAuth returns a promise so the resolve waits for it to complete
// If the promise is rejected, it will throw a $stateChangeError (see above)
return Auth.$requireAuth();
}]
}
});
}]);
My controller file 我的控制器文件
var pgpChatAppControllers = angular.module('pgpChatAppControllers', []);
pgpChatAppControllers.controller("userAuth", ["$scope", "$routeParams", "Auth",
function ($scope, $routeParams, Auth) {
$scope.createUser = function () {
$scope.message = null;
$scope.error = null;
Auth.$createUser({
email: $scope.email,
password: $scope.password
}).then(function (userData) {
$scope.message = "User created with uid: " + userData.uid;
}).catch(function (error) {
$scope.error = error;
});
};
$scope.removeUser = function () {
$scope.message = null;
$scope.error = null;
Auth.$removeUser({
email: $scope.email,
password: $scope.password
}).then(function () {
$scope.message = "User removed";
}).catch(function (error) {
$scope.error = error;
});
};
}]);
Has anyone got an idea what the fix is? 有谁知道解决方案是什么?
Thanks in advanced 提前致谢
[EDIT] Full exception message [EDIT]完整的异常消息
http://errors.angularjs.org/1.3.15/ $injector/modulerr?p0=pgpChatAnimations&p1=Error: [$injector:nomod] http://errors.angularjs.org/1.3.15/ $injector/nomod?p0=pgpChatAnimations at Error (native) at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:6:417 at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:21:412 at a ( https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:21:53 ) at w.bootstrap ( https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:21:296 ) at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:35:116 at r ( https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:7:302 ) at g ( https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:34:399 ) at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:35:63 at r ( https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:7:302 )" http://errors.angularjs.org/1.3.15/ $ injector / modulerr?p0 = pgpChatAnimations&p1 =错误:[$ injector:nomod] http://errors.angularjs.org/1.3.15/ $ injector / nomod? p0 = pgpChatAnimations错误(本机),位于https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:6:417 , 网址为https://ajax.googleapis.com/ajax /libs/angularjs/1.3.15/angular.min.js:21:412 ,位于( https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:21:53 ), 网址为https://ajax.googleapis.com/ajax/libs , 网址为w.bootstrap( https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:21:296 ) / r的/angularjs/1.3.15/angular.min.js:35:116(位于https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:7:302 ) g( https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:34:399 )在https://ajax.googleapis.com/ajax/libs/angularjs/1.3 .15 / angular.min.js:35:63 at r( https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:7:302 )”
The url for angular-route is not working. angular-route的网址无效。 Try using: 尝试使用:
http://code.angularjs.org/1.2.0-rc.3/angular-route.js
I guess i my module names still weren't matching the defined modules in app.js 我想我的模块名称仍然与app.js中定义的模块不匹配
This diff shows the fix 此差异显示了解决方法
https://github.com/jkirkby91/angular-firebase-chat/commit/35be74592197d16435adb322f0e24963108ed97a https://github.com/jkirkby91/angular-firebase-chat/commit/35be74592197d16435adb322f0e24963108ed97a
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.