Angular: 'modulerr', "实例化模块失败

Angular: 'modulerr', "Failed to instantiate module

本文关键字:实例化 模块 失败 quot modulerr Angular      更新时间:2023-09-26

我正在努力学习Angular,在尝试向我的应用程序中添加路由时遇到了瓶颈。

总是出现这个错误

'modulerr', "实例化模块失败

从其他stackoverflow问题我收集它不是从加载ngRoute正确,但angular-route.js加载在头部,和ngRoute声明在我的模块结构,所以我有点困惑

我的索引文件如下

<!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();
      }]
    }
  });
}]);

我的控制器文件

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;
      });
    };
  }]);

有谁知道修复是什么吗?

Thanks in advanced

[编辑]完整异常消息

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=pgpChatAnimationsat Error (native)在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:412a (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:21:53)在w.bootstrap (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:21:296)在https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js: 35:116At 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)在https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js: 35:63At r (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js:7:302)"

angular-route的url不能正常工作。尝试使用:

http://code.angularjs.org/1.2.0-rc.3/angular-route.js

我猜我的模块名称仍然不匹配app.js中定义的模块

显示修复

https://github.com/jkirkby91/angular-firebase-chat/commit/35be74592197d16435adb322f0e24963108ed97a