带有vendor.min.js的angular.js出现错误:[$ injector:modulerr]

时间:2018-07-11 09:57:28

标签: angularjs

我正在尝试将require.js与Main.js结合使用,并出现以下错误:

http://errors.angularjs.org/1.4.12/ $ injector / modulerr?p0 = bleepMed&p1 = Error%3 (http%3A%2F%2Flocalhost%3A8000%2Fjs%2Fvendor.min.js%3A25%3A274)

我的Main.js

'use strict';
Array.prototype.contains = function(obj) {
var i = this.length;
while (i--) {
    if (this[i] === obj) {
        return true;
    }
}
return false;
};


angular.module('bleepMed', [
' ui.router',
'angular-loading-bar',
'ngAnimate',
'ui.bootstrap',
'ui.bootstrap.datetimepicker',
'angular-ui-validator',
'toastr',
'angular-uuid',
'colorpicker.module',
'naif.base64',
'highcharts-ng',
'ui.gravatar',
'ds.clock',
'sun.scrollable',
'ngFileUpload',
'countTo',
'angularMoment',
'ngSanitize',
'textAngular',
'ui.grid',
'ui.grid.resizeColumns',
'ui.grid.pagination',
'ngDraggable',
'timer',
require('./common').name,
require('./config').name,
require('./modules').name,
require('./util').name
])

.config(['cfpLoadingBarProvider', '$urlRouterProvider', 'AppConfig', 'toastrConfig', '$locationProvider', function(cfpLoadingBarProvider, $urlRouterProvider, AppConfig, toastrConfig, $locationProvider) {
    //for angular bar loading
    cfpLoadingBarProvider.includeSpinner = false;
    $urlRouterProvider.when('/', ['$state', 'loggedInUser', function($state, loggedInUser) {
        if (!Object.keys(loggedInUser.getData()).length) {
            $state.go('login');
        } else {
            $state.go('admin.home');
        }
    }]);
    angular.extend(toastrConfig, AppConfig.toastr);
    // $locationProvider.html5Mode(true).hashPrefix('*');
    // $translateProvider
    //     .useStaticFilesLoader({
    //         prefix: '/translations/',
    //         suffix: '.json'
    //     })
    //     .preferredLanguage('en')
    //     .useMissingTranslationHandlerLog();

}])
// .constant('moment', require('moment-timezone'))
.run([
    '$rootScope',
    '$injector',
    'loggedInUser',
    '$state',
    'toastr',
    '$timeout',
    '$window',
    'AppConfig',
    'API',

    function($rootScope, $injector, loggedInUser, $state, toastr, $timeout, $window, AppConfig, API) {
      console.log("in......");
        $rootScope.googleChartLoaded = false;
        $rootScope.picUrl = API.picUrl;
        $rootScope.$on('$stateChangeStart', function(event, toState, fromState) {
            if (Object.keys(loggedInUser.getData()).length && (toState.name.indexOf('login') > -1)) {
                event.preventDefault();
            }
            if (!Object.keys(loggedInUser.getData()).length && (toState.name.indexOf('admin') > -1)) {
                event.preventDefault();
                $state.go('login');
            }
        });

        $rootScope.$on('$stateChangeSuccess', function() {
            $rootScope.loadingText = '';
            $rootScope.pageLoading = false;
        });

        $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {
            $rootScope.pageLoading = false;
        });

        $rootScope.$on('invalidToken', function() {
            $state.go('login');
        });
        //for google chart//
        google.charts.load('current', {
            'packages': ['corechart', 'bar']
        });

        function googleChartLoadedCallback() {
            $timeout(function() {
                // console.log('here in timeout');
                $rootScope.googleChartLoaded = true;
                $rootScope.$broadcast('chartLoaded', {});
            }, 0);
        }
        google.charts.setOnLoadCallback(googleChartLoadedCallback);

        $rootScope.goBack = function() {
            $window.history.back();
        };

        //mqtt starts
        $rootScope.client = mqtt.connect(API.mqtt);
        $rootScope.client.on('connect', function() {
            console.log('connected');
        });
        $rootScope.client.on('subscribe', function() {
            console.log('subscribe');
        });
    }
]);

我的index.html

 <!DOCTYPE html>
 <html ng-app="bleepMed">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, 
 maximum-scale=1">
<!-- <base href="/"> -->
<title>Bleep Med</title>
<!--Stylesheet-->
<link rel="stylesheet" type="text/css" href="./css/vendor.min.css">
<link rel="stylesheet" type="text/css" href="./css/app.min.css">
</head>

<body>
<div ui-view ng-class="moduleClass" class="full-height ui-view-class"> 
</div>
<!--   <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCV7dBG_5koAJ_HmwRDEc7l4jezGbpHyfs&libraries=places">
</script> -->

<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCCE7DhZbQJ8-ki453Z2JdGzPJdMZ5o5JM&libraries=places"></script>
<script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="resources/js/mqtt.js"></script>
<script src="./js/vendor.min.js"></script>
<script src="./js/main.min.js"></script>
</body>
</html>

我遇到一个错误,说我需要将ngroute添加到我的应用程序中,但仍然出现此错误。谁能指出我可能做错了什么?

我的确切错误是:

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.1/$injector/modulerr?p0=bleepMed&p1=Error%3A%20%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.2.1%2F%24injector%2Fmodulerr%3Fp0%3Dsun.scrollable%26p1%3DError%253A%2520%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.2.1%252F%2524injector%252Fnomod%253Fp0%253Dsun.scrollable%250A%2520%2520%2520%2520at%2520https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.2.1%252Fangular.min.js%253A6%253A447%250A%2520%2520%2520%2520at%2520https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.2.1%252Fangular.min.js%253A20%253A159%250A%2520%2520%2520%2520at%2520a%2520(https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.2.1%252Fangular.min.js%253A19%253A353)%250A%2520%2520%2520%2520at%2520https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.2.1%252Fangular.min.js%253A20%253A54%250A%2520%2520%2520%2520at%2520https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.2.1%252Fangular.min.js%253A28%253A487%250A%2520%2520%2520%2520at%2520Array.forEach%2520(%253Canonymous%253E)%250A%2520%2520%2520%2520at%2520p%2520(https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.2.1%252Fangular.min.js%253A7%253A255)%250A%2520%2520%2520%2520at%2520e%2520(https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.2.1%252Fangular.min.js%253A28%253A427)%250A%2520%2520%2520%2520at%2520https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.2.1%252Fangular.min.js%253A28%253A504%250A%2520%2520%2520%2520at%2520Array.forEach%2520(%253Canonymous%253E)%0A%20%20%20%20at%20https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.1%2Fangular.min.js%3A6%3A447%0A%20%20%20%20at%20https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.1%2Fangular.min.js%3A29%3A279%0A%20%20%20%20at%20Array.forEach%20(%3Canonymous%3E)%0A%20%20%20%20at%20p%20(https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.1%2Fangular.min.js%3A7%3A255)%0A%20%20%20%20at%20e%20(https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.1%2Fangular.min.js%3A28%3A427)%0A%20%20%20%20at%20https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.1%2Fangular.min.js%3A28%3A504%0A%20%20%20%20at%20Array.forEach%20(%3Canonymous%3E)%0A%20%20%20%20at%20p%20(https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.1%2Fangular.min.js%3A7%3A255)%0A%20%20%20%20at%20e%20(https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.1%2Fangular.min.js%3A28%3A427)%0A%20%20%20%20at%20Yb%20(https%3A%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.1%2Fangular.min.js%3A32%3A462)

1 个答案:

答案 0 :(得分:-1)

Angular在无法加载任何模块时抛出此错误。 在您的示例中,ui.router中有一个错字。在模块名称之前添加了额外的空格,这可能会引发错误。

  

编辑:

您复制的错误表明您正在使用名为sun.scrollable的模块,尚未加载。您是否正在加载所需的模块js文件?