AngularJs show Error: [$injector:modulerr] in console?

AngularJs show Error: [$injector:modulerr] in console?

HTML

<!DOCTYPE html>
<html ng-app="adaniapp">
<head>
  <link rel="stylesheet" href="css/bootstrap.min.css" />
  <link rel="stylesheet" href="css/font-awesome.css" />
  <link rel="stylesheet" href="css/style.css" />
</head>
<body>
    <div id="main">
        <div ng-view></div>
    </div>
  <script src="js/angular.min.js"></script>
  <script src="js/angular-route.js"></script>
  <script src="js/angular-resource.min.js"></script>
  <script src="js/app.js"></script>

</body>
</html>

Javascript

var adaniapp = angular.module('adaniapp', ['ngRoute','ngResource']);
// configure our routes
adaniapp.config(['$scope', '$routeProvider', '$resource',function($scope, $routeProvider, $resource) {
    $routeProvider

        // route for the home page
        .when('/', {
            templateUrl : 'page/login.html',
            controller  : 'mainController'
        })

        // route for the about page
        .when('/home', {
            templateUrl : 'page/home.html',
            controller  : 'HomeController'
        })

        // route for the contact page
        .when('/meter', {
            templateUrl : 'page/meter.html',
            controller  : 'MeterController'
        })

        .when('/viewbill', {
            templateUrl : 'page/viewbill.html',
            controller  : 'ViewbillController'
        });
}]);

// create the controller and inject Angular's $scope
adaniapp.controller('mainController',['$scope', '$routeProvider', '$resource', function($scope, $routeProvider, $resource) {

}]);

adaniapp.controller('HomeController',['$scope', '$routeProvider', '$resource', function($scope, $routeProvider, $resource) {

}]);

adaniapp.controller('MeterController',['$scope', '$routeProvider', '$resource', function($scope, $routeProvider, $resource) {

}]);

adaniapp.controller('MeterController',['$scope', '$routeProvider', '$resource', function($scope, $routeProvider, $resource) {

}]);

包含的 ng-resource.js 文件和 route.js 文件包含在 index.html 中,但它仍然在我的控制台中显示错误

"Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0="

包括所有控制器。

我猜您实际上遗漏了一些脚本。尝试使用 bower 安装它们,如果不使用 bower,则手动添加它们。 angular-route.js 不包含在 angular 中的情况尤其常见。如果您的 Web 开发人员控制台中有任何 404,它们将有助于确认这种怀疑(尽管如果以不寻常的方式配置,您的 Web 服务器可能不会将它们作为 404 服务)。

  1. 您无法在配置阶段注入 $scope

Configuration blocks - get executed during the provider registrations and configuration phase. Only providers and constants can be injected into configuration blocks. This is to prevent accidental instantiation of services before they have been fully configured.

  1. 您不能在控制器中注入 $routeProvider,因为它已经配置,请改用 $route 服务。